Php Cheat Sheet

ADVERTISEMENT

Arrays
Regex
array_intersect
ereg
array_merge
eregi
^
Y
Start of string
4 digit year
2005
array_pop
ereg_replace
array_push
eregi_replace
$
End of string
y
2 digit year
05
array_reverse
split
.
Any single character
F
Long month
January
array_walk
spliti
(a|b)
a or b
M
Short month
Jan
count
preg_match
(...)
Group section
m
Month (leading zeros)
01 to 12
in_array
preg_match_all
preg_replace
[abc]
Item in range (a or b or c)
n
Month
1 to 12
Date and Time
preg_split
[^abc]
Not in range (not a or b or c)
D
Short day name
Mon
date
\s
White space
l
Long day name
Monday
mktime
Sessions
a?
d
Zero or one of a
Day (leading zeros)
01 to 31
strtotime
session_destroy
time
session_id
a*
j
Zero or more of a
Day
1 to 31
session_start
a+
One or more of a
Filesystem
a{3}
h
Exactly 3 of a
12 Hour (leading zeros)
01 to 12
clearstatcache
Strings
a{3,}
g
3 or more of a
12 Hour
1 to 12
copy
addslashes
fclose
crypt
a{3,6}
H
Between 3 and 6 of a
24 Hour (leading zeros)
00 to 23
fgets
echo
\
G
Escape character
24 Hour
0 to 23
file
explode
i
Minutes (leading zeros)
00 to 59
filemtime
implode
[:punct:]
Any punctuation symbol
s
Seconds (leading zeros)
00 to 59
filesize
md5
file_exists
nl2br
[:space:]
Any space character
fopen
sprintf
[:blank:]
Space or tab
w
Day of week
0 to 6
1
fread
strip_tags
z
Day of year
0 to 365
fwrite
stripslashes
W
Week of year
1 to 53
is_dir
stristr
2
is_file
strpos
t
Days in month
28 to 31
readfile
strrev
i
Case-insensitive
strstr
a
am or pm
s
Period matches newline
Headers
strtolower
A
AM or PM
header
strtoupper
m
^ and $ match lines
headers_sent
str_replace
B
Swatch Internet Time
000 to 999
U
Ungreedy matching
setcookie
substr
S
Ordinal Suffix
st, nd, td, th
e
Evaluate replacement
trim
x
Pattern over several lines
Mail
T
Timezone of machine
GMT
mail
URLs
rawurldecode
Z
Timezone offset (seconds)
Numbers
rawurlencode
O
Difference to GMT (hours)
+0200
ceil
urldecode
I
Daylight savings
1 or 0
floor
urlencode
array_push ( array, element )
L
Leap year
1 or 0
number_format
in_array ( needle, haystack )
round
Variables
explode ( separator, string )
empty
U
Seconds since Epoch
3
Miscellaneous
is_array
split ( pattern, string )
c
ISO 8601 (PHP 5)
define
is_int
preg_split ( pattern, string )
r
RFC 2822
eval
is_null
ereg ( pattern, string )
exit
is_numeric
strpos ( haystack, needle )
date("w"): 0 is Sunday, 6 is Saturday.
1.
is_object
Network
isset
str_replace ( search, replace, string )
fsockopen
serialize
2.
Week that overlaps two years belongs to
unserialize
year that contains most days of that
PHP Options
ini_get
week. Hence week number for 1st January
SuperGlobals
ini_restore
$_ENV
of a given year can return 53rd week if
r
Read
ini_set
$_GET
week belongs to previous year.
phpinfo
$_POST
r+
Read and write, prepend
date("W", mktime(0, 0, 0, 12, 28, $year))
$_COOKIE
w
Write, truncate
Execution
always gives correct number of weeks in
$_SESSION
w+
Read and write, truncate
exec
$_SERVER
$year.
a
Write, append
$_FILES
a+
$_REQUEST
Read and write, append
The Epoch was the 1st January 1970.
3.
$GLOBALS
Available free from

ADVERTISEMENT

00 votes

Related Articles

Related forms

Related Categories

Parent category: Education
Go