Home >Backend Development >PHP Tutorial >PHP function accumulation summary_PHP tutorial
Math function:
10 of the more commonly used ones are marked red.
abs — absolute value
acos — inverse cosine
acosh — inverse hyperbolic cosine
asin — arcsine
asinh — inverse hyperbolic sine
atan2 — arctangent of two parameters
atan — arctangent
atanh — inverse hyperbolic tangent
base_convert — Convert numbers between arbitrary bases
bindec — Convert binary to decimal
ceil — round to the next nearest whole
cos — cosine
cosh — hyperbolic cosine
decbin — Convert decimal to binary
dechex — Convert decimal to hexadecimal
decoct — Convert decimal to octal
deg2rad — Convert angles to radians
exp — Compute the exponent of e
expm1 — Returns exp(number) - 1, which can be calculated accurately even when number is close to zero
floor — Rounding by rounding
fmod — Returns the floating point remainder of division
getrandmax — displays the largest possible value of a random number
hexdec — Convert hexadecimal to decimal
hypot — Calculate the length of the hypotenuse of a right triangle
is_finite — Determine whether it is a finite value
is_infinite — Determine whether the value is infinite
is_nan — Determine whether it is a legal value
lcg_value — Combinatorial linear congruential generator
log10 — Logarithm to base 10
log1p — Returns log(1 + number), which can be calculated accurately even when the value of number is close to zero
log — natural logarithm
max — find the maximum value
min — find the minimum value
mt_getrandmax — Display the maximum possible value of a random number
mt_rand — Generate better random numbers
mt_srand — Sow a better random number generator
octdec — Convert octal to decimal
pi — get the value of pi
pow — exponential expression
rad2deg — Convert radians to corresponding degrees
rand — Generate a random integer
round — Round floating point numbers
sin — sine
sinh — hyperbolic sine
sqrt — square root
srand — Seed a random number generator
tan — tangent
tanh — hyperbolic tangent
String functions:
The more the merrier, at least master 20. More commonly marked red.
addcslashes — Escape characters in a string using backslashes in C style
addslashes — Use backslashes to quote strings
bin2hex — Convert binary data to hexadecimal representation
chop — alias for rtrim
chr — Returns the specified character
chunk_split — Split a string into small chunks
convert_cyr_string — Convert a character from one Cyrillic character to another
convert_uudecode — Decode a uuencode-encoded string
convert_uuencode — Encode a string using uuencode
count_chars — Returns information about the characters used in a string
crc32 — Compute the crc32 polynomial of a string
crypt — One-way string hashing
echo — Output one or more strings
explode — Split one string into another
fprintf — Write a formatted string to a stream
get_html_translation_table — Returns the translation table using htmlspecialchars and htmlentities
hebrev — Convert logical-Hebrew to visual-Hebrew
hebrevc — Convert logical-Hebrew to visual-Hebrew, converting newlines
html_entity_decode — Convert all HTML entities to their applicable characters
htmlentities — Convert all applicable characters to HTML entities
htmlspecialchars_decode — Convert special HTML entities back to characters
htmlspecialchars — Convert special characters to HTML entities
implode — Join array elements with a string
join — alias implode
lcfirst — Make a string's first character lowercase
levenshtein — Calculate Levenshtein distance between two strings
localeconv — Get numeric formatting information
ltrim — Strip whitespace (or other characters) from the beginning of a string
md5_file — Calculate the MD5 hash value of the specified file
md5 — Computes the MD5 hash of a string
metaphone — Calculate the metaphone key of a string
money_format — Formats a number as a currency string
nl_langinfo — Query language and locale information
nl2br — Insert an HTML line break
before all new lines in a string
number_format — Format a number with grouped thousands
ord — Returns the ASCII code value of the character
parse_str — Parses the string into variables
print — output string
printf — output formatted string
quoted_printable_decode — Convert a quoted-printable string to an 8 bit string
quoted_printable_encode — Convert a 8 bit string to a quoted-printable string
quotemeta — Quote meta characters
rtrim — Remove whitespace characters (or other characters) from the end of a string
setlocale — Set locale information
sha1_file — Compute the sha1 hash of a file
sha1 — Compute the sha1 hash value of a string
similar_text — Calculate the similarity between two strings
soundex — Calculate the soundex key of a string
sprintf — Return a formatted string
sscanf — Parses input from a string according to a format
str_getcsv — Parse a CSV string into an array
str_ireplace — Case-ignoring version of str_replace
str_pad — Pad a string to a specified length with another string
str_repeat — Repeat a string
str_replace — Substring replacement
str_rot13 — performs a ROT13 conversion on a string
str_shuffle — randomly shuffle a string
str_split — Convert a string to an array
str_word_count — Returns the usage of words in a string
strcasecmp — Binary safe comparison of strings (case insensitive)
strchr — alias strstr
strcmp — Binary safe string comparison
strcoll — Locale-based string comparison
strcspn — Get the length of the starting substring of the non-matching mask
strip_tags — Strip HTML and PHP tags from strings
stripcslashes — dequote a string escaped using addcslashes
stripos — Find the first occurrence of a string (case insensitive)
stripslashes — backquote a quoted string
stristr — A case-ignoring version of the strstr function
strlen — Get the length of a string
strnatcasecmp — Compare strings using the "natural order" algorithm (case-insensitive)
strnatcmp — Compare strings using natural ordering algorithm
strncasecmp — Binary safe comparison of several characters at the beginning of a string (case insensitive)
strncmp — Binary safe comparison of several characters at the beginning of a string
strpbrk — Find any character in a set of characters in a string
strpos — Find the first occurrence of a string
strrchr — Find the last occurrence of a specified character in a string
strrev — Reverse a string
strripos — Calculate the position of the last occurrence of the specified string in the target string (case-insensitive)
strrpos — Calculate the position of the last occurrence of the specified string in the target string
strspn — Calculates the length of the first substring of a string in which all characters are present in the specified character set.
strstr — Find the first occurrence of a string
strtok — token split string
strtolower — Convert a string to lowercase
strtoupper — Convert a string to uppercase
strtr — Convert the specified character
substr_compare — Binary safe comparison of strings (specified length compared from offset position)
substr_count — Count the number of occurrences of a string
substr_replace — Replace a substring of a string
substr — Returns a substring of a string
trim — remove whitespace characters (or other characters) at the beginning and end of a string
ucfirst — Convert the first letter of a string to uppercase
ucwords — Convert the first letter of each word in a string to uppercase
vfprintf — Write a formatted string to a stream
vprintf — Output formatted string
vsprintf — Returns a formatted string
wordwrap — breaks a string into a specified number of words
Array function
The more the merrier, at least master 15. More commonly marked red.
array_change_key_case — Returns an array whose string keys are all lowercase or uppercase
array_chunk — Split an array into multiple
array_combine — Create an array with values from one array as keys and values from another array
array_count_values — Count the number of occurrences of all values in an array
array_diff_assoc — Compute the difference of an array with index checking
array_diff_key — Compute the difference of an array using key name comparison
array_diff_uassoc — Compute the difference of an array using a user-supplied callback function with index checking
array_diff_ukey — Use callback function to compare key names to calculate the difference of array
array_diff — Calculate the difference of arrays
array_fill_keys — Fill an array with specified keys and values
array_fill — Fill an array
with the given values
array_filter — Filter elements in an array using a callback function
array_flip — swap keys and values in an array
array_intersect_assoc — Compute the intersection of arrays with index checking
array_intersect_key — Compute the intersection of arrays using key comparison
array_intersect_uassoc — Compute the intersection of arrays with index checking, using a callback function to compare the indices
array_intersect_ukey — Compute the intersection of arrays using callback functions to compare keys
array_intersect — Compute the intersection of arrays
array_key_exists — Check if a given key or index exists in an array
array_keys — Returns all key names in the array
array_map — apply a callback function to the cells of the given array
array_merge_recursive — Merge one or more arrays recursively
array_merge — Merge one or more arrays
array_multisort — Sort multiple arrays or multidimensional arrays
array_pad — Pad an array to a specified length with values
array_pop — pop the last element of the array
array_product — Calculates the product of all values in an array
array_push — Push one or more elements to the end of an array (push)
array_rand — Randomly remove one or more elements from an array
array_reduce — Iteratively reduce an array to a single value using a callback function
array_replace_recursive — Recursively replace elements of the first array with the passed array
array_replace — Replace elements of the first array with the passed array
array_reverse — Returns an array with the cells in reverse order
array_search — Search for a given value in an array, returning the corresponding key if successful
array_shift — Shift the elements at the beginning of the array out of the array
array_slice — Remove a segment
from an array
array_splice — Remove part of an array and replace it with another value
array_sum — Calculates the sum of all values in an array
array_udiff_assoc — Computes the difference of arrays with index checking, using callback functions to compare data
array_udiff_uassoc — Calculate the difference of an array with index checking, using a callback function to compare the data and index
array_udiff — Use callback functions to compare data to calculate the difference of arrays
array_uintersect_assoc — Compute the intersection of arrays with index checking and compare data using callback functions
array_uintersect_uassoc — Compute the intersection of arrays with index checking, using a callback function to compare data and index
array_uintersect — Calculate the intersection of arrays and use callback functions to compare data
array_unique — Remove duplicate values from an array
array_unshift — Insert one or more cells at the beginning of an array
array_values — Returns all values in an array
array_walk_recursive — Recursively apply a user function to each member of an array
array_walk — Apply a user function to each member of an array
array — Create a new array
arsort — Sort an array in reverse order while maintaining index relationships
asort — Sort an array while maintaining index relationships
compact — Create an array including variable names and their values
count — Count the number of cells in an array or the number of attributes in an object
current — Returns the current element in the array
each — Returns the current key/value pair in the array and moves the array pointer forward one step
end — Set the internal pointer of the array to the last element
extract — Import variables from an array into the current symbol table
in_array — Check if a value exists in an array
key — Get the key name from an associative array
krsort — Sort an array in reverse order by key
ksort — Sort an array by key
list — Assign the values in an array to some variables
natcasesort — Case-insensitive sorting of an array using the "natural sort" algorithm
natsort — Sort an array using the "natural sorting" algorithm
next — Move the internal pointer in the array forward one position
pos — alias for current
prev — rewind the array’s internal pointer one bit
range — Create an array containing cells in the specified range
reset — Set the array’s internal pointer to the first element
rsort — Sort an array in reverse order
shuffle — shuffle an array
sizeof — alias for count
sort — Sort an array
uasort — Sort values in an array using a user-defined comparison function and maintain index association
uksort — Sort keys in an array using a user-defined comparison function
usort — Sort values in an array using a user-defined comparison function