Show Menu
Cheatography

PHP cheatsheet Cheat Sheet by

PHP Common Cheat Sheet

PHP Arrays

array_­filter (input, [callback])
array_­key­_exists (strtolower($key), array_­cha­nge­_ke­y_case($search))
array_walk (&­$array, callba­ck(­val,key), userdata)
array_map (callback, array1, [array2,...])
array_­search (needle, haystack, [strict])
array_push (&­$array, var1,[­var2])
array_pop (&­$array)
array_­unshift (&­$array, var1,[­var2])
array_­shift (&­$array)
count(array)
in_array (needle, haystack, strict)
array_­unique (array, [sort_­flag])
array_diff(array1, array2, [array­3...])
array_­int­ersect(array1, array2, [array­3...])
array_rand(array, [num])

PHP String

substr­_count (haystack, needle­,[o­ffset, length])
strpos (haystack, needle, [offset]) (compare only with ===)
stripos (haystack, needle, [offset])
strrpos (haystack, needle, [offset])
strripos (haystack, needle, [offset])
ord (symbol)
chr (ascii)
strip_tags (str, [allow­abl­e_tags])
number­_format (number, decimals, dec.point, th. sep)
join (glue, array)
strstr (haystack, needle, [befor­e_n­eedle])
strlen (string)
parse_str (string, [& array])
flush ()
 

PHP Math

ceil()
floor()
round()
abs()
mt_rand([min=0, max=RA­ND_MAX])
 

PHP fopen() modes

r
read; pointer at start
r+
read/w­rite; pointer at start
w
write; clean on start; create if not exists
w+
write/­read; same
a
write; pointer at end; create if not exists
a+
write/­read; pointer at end
x
write
x+
write/read
c
write
c+
write/read

PHP Filesystem

is_dir (filename)
is_file (filename)
is_exe­cutable (filename)
is_link (filename)
is_wri­table (filename)
is_rea­dable (filename)
file_e­xists (filename)
file_g­et_­con­tents (filena­me,­[in­clu­de_­pat­h,r­eso­urc­e,o­ffs­et,­maxlen])
disk_t­ota­l_space (dir)
disk_f­ree­_space (dir)
dirname (path)
realpath (filename)
pathinfo (path [,PATH­INF­O_D­IRNAME | PATHIN­FO_­BAS­ENAME | PATHIN­FO_­EXT­ENSION | PATHIN­FO_­FIL­ENAME ] )
scandir(dir, [order])
               
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          PHP Cheat Sheet
          PHP Cheat Sheet
          PHP8 - What's New In PHP8? Cheat Sheet

          More Cheat Sheets by media_slave