Show Menu
Cheatography

PHP functions for ZCE Cheat Sheet (DRAFT) by

Array and String functions

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Array functions

array array_­cha­nge­_ke­y_case ( array $array [, int $case = CASE_LOWER ] )
Returns an array with all keys from array lowercased or upperc­ased. Numbered indices are left as is.
Returns an array with its keys lower or upperc­ased, or FALSE if array is not an array.
array array_­chunk ( array $array , int $size [, bool $prese­rve­_keys = false ] )
Chunks an array into arrays with size elements. The last chunk may contain less than size elements.
Returns a multid­ime­nsional numeri­cally indexed array, starting with zero, with each dimension containing size elements.
array array_­column ( array $input , mixed $colum­n_key [, mixed $index_key = null ] )
returns the values from a single column of the input, identified by the column­_key. Option­ally, an index_key may be provided to index the values in the returned array by the values from the index_key column of the input array.
Returns an array of values repres­enting a single column from the input array.
array array_­combine ( array $keys , array $values )
Creates an array by using the values from the keys array as keys and the values from the values array as the corres­ponding values.
Returns the combined array, FALSE if the number of elements for each array isn't equal.
array array_­cou­nt_­values ( array $array )
array_­cou­nt_­val­ues() returns an array using the values of array as keys and their frequency in array as values.
Returns an associ­ative array of values from array as keys and their count as value.
array array_­dif­f_assoc ( array $array1 , array $array2 [, array $... ] )
Compares array1 against array2 and returns the differ­ence. Unlike array_­diff() the array keys are also used in the compar­ison.
Returns an array containing all the values from array1 that are not present in any of the other arrays.
array array_­dif­f_key ( array $array1 , array $array2 [, array $... ] )
Compares the keys from array1 against the keys from array2 and returns the differ­ence. This function is like array_­diff() except the comparison is done on the keys instead of the values.
Returns an array containing all the entries from array1 whose keys are not present in any of the other arrays.
array array_­dif­f_u­assoc ( array $array1 , array $array2 [, array $... ], callable $key_c­omp­are­_func )
Compares array1 against array2 and returns the differ­ence. Unlike array_­diff() the array keys are used in the compar­ison. Unlike array_­dif­f_a­ssoc() an user supplied callback function is used for the indices compar­ison, not internal function.
Returns an array containing all the entries from array1 that are not present in any of the other arrays.
array array_­dif­f_ukey ( array $array1 , array $array2 [, array $... ], callable $key_c­omp­are­_func )
Compares the keys from array1 against the keys from array2 and returns the differ­ence. This function is like array_­diff() except the comparison is done on the keys instead of the values. Unlike array_­dif­f_key() a user supplied callback function is used for the indices compar­ison, not internal function.
Returns an array containing all the entries from array1 that are not present in any of the other arrays.
array array_diff ( array $array1 , array $array2 [, array $... ] )
Compares array1 against one or more other arrays and returns the values in array1 that are not present in any of the other arrays.
Returns an array containing all the entries from array1 that are not present in any of the other arrays.
array array_­fil­l_keys ( array $keys , mixed $value )
Fills an array with the value of the value parameter, using the values of the keys array as keys.
Returns the filled array
array array_fill ( int $start­_index , int $num , mixed $value )
Fills an array with num entries of the value of the value parameter, keys starting at the start_­index parameter.
Returns the filled array
array array_­filter ( array $array [, callable $callback [, int $flag = 0 ]] )
Iterates over each value in the array passing them to the callback function. If the callback function returns true, the current value from array is returned into the result array. Array keys are preserved.
Returns the filtered array.
array array_flip ( array $array )
array_­flip() returns an array in flip order, i.e. keys from array become values and values from array become keys. Note that the values of array need to be valid keys, i.e. they need to be either integer or string. A warning will be emitted if a value has the wrong type, and the key/value pair in question will not be included in the result. If a value has several occurr­ences, the latest key will be used as its value, and all others will be lost.
Returns the flipped array on success and NULL on failure.
array array_­int­ers­ect­_assoc ( array $array1 , array $array2 [, array $... ] )
array_­int­ers­ect­_as­soc() returns an array containing all the values of array1 that are present in all the arguments. Note that the keys are also used in the comparison unlike in array_­int­ers­ect().
Returns an associ­ative array containing all the values in array1 that are present in all of the arguments.
array array_­int­ers­ect_key ( array $array1 , array $array2 [, array $... ] )
array_­int­ers­ect­_key() returns an array containing all the entries of array1 which have keys that are present in all the arguments.
Returns an associ­ative array containing all the entries of array1 which have keys that are present in all arguments.
array array_­int­ers­ect­_uassoc ( array $array1 , array $array2 [, array $... ], callable $key_c­omp­are­_func )
array_­int­ers­ect­_ua­ssoc() returns an array containing all the values of array1 that are present in all the arguments. Note that the keys are used in the comparison unlike in array_­int­ers­ect().
Returns the values of array1 whose values exist in all of the arguments.
array array_­int­ers­ect­_ukey ( array $array1 , array $array2 [, array $... ], callable $key_c­omp­are­_func )
array_­int­ers­ect­_ukey() returns an array containing all the values of array1 which have matching keys that are present in all the arguments.
Returns the values of array1 whose keys exist in all the arguments.
array array_­int­ersect ( array $array1 , array $array2 [, array $... ] )
array_­int­ers­ect() returns an array containing all the values of array1 that are present in all the arguments. Note that keys are preserved.
Returns an array containing all of the values in array1 whose values exist in all of the parame­ters.
bool array_­key­_exists ( mixed $key , array $array )
array_­key­_ex­ists() returns TRUE if the given key is set in the array. key can be any value possible for an array index.
Returns TRUE on success or FALSE on failure.
array array_keys ( array $array [, mixed $searc­h_value = null [, bool $strict = false ]] )
array_­keys() returns the keys, numeric and string, from the array. If the optional search­_value is specified, then only the keys for that value are returned. Otherwise, all the keys from the array are returned.
Returns an array of all the keys in array.
array array_map ( callable $callback , array $array1 [, array $... ] )
array_­map() returns an array containing all the elements of array1 after applying the callback function to each one. The number of parameters that the callback function accepts should match the number of arrays passed to the array_­map()
Returns an array containing all the elements of array1 after applying the callback function to each one.
array array_­mer­ge_­rec­ursive ( array $array1 [, array $... ] )
array_­mer­ge_­rec­urs­ive() merges the elements of one or more arrays together so that the values of one are appended to the end of the previous one. It returns the resulting array. If the input arrays have the same string keys, then the values for these keys are merged together into an array, and this is done recurs­ively, so that if one of the values is an array itself, the function will merge it with a corres­ponding entry in another array too. If, however, the arrays have the same numeric key, the later value will not overwrite the original value, but will be appended.
An array of values resulted from merging the arguments together.
array array_­merge ( array $array1 [, array $... ] )
Merges the elements of one or more arrays together so that the values of one are appended to the end of the previous one. It returns the resulting array. If the input arrays have the same string keys, then the later value for that key will overwrite the previous one. If, however, the arrays contain numeric keys, the later value will not overwrite the original value, but will be appended. Values in the input array with numeric keys will be renumbered with increm­enting keys starting from zero in the result array.
Returns the resulting array.
bool array_­mul­tisort ( array &$­array1 [, mixed $array­1_s­ort­_order = SORT_ASC [, mixed $array­1_s­ort­_flags = SORT_R­EGULAR [, mixed $... ]]] )
array_­mul­tis­ort() can be used to sort several arrays at once, or a multi-­dim­ens­ional array by one or more dimens­ions. Associ­ative (string) keys will be mainta­ined, but numeric keys will be re-ind­exed.
Returns TRUE on success or FALSE on failure.
array array_pad ( array $array , int $size , mixed $value )
array_­pad() returns a copy of the array padded to size specified by size with value value. If size is positive then the array is padded on the right, if it's negative then on the left. If the absolute value of size is less than or equal to the length of the array then no padding takes place. It is possible to add at most 1048576 elements at a time.
Returns a copy of the array padded to size specified by size with value value. If size is positive then the array is padded on the right, if it's negative then on the left. If the absolute value of size is less than or equal to the length of the array then no padding takes place.
mixed array_pop ( array &$­array )
array_­pop() pops and returns the last value of the array, shortening the array by one element.
Note: This function will reset() the array pointer of the input array after use.
Returns the last value of array. If array is empty (or is not an array), NULL will be returned.
number array_­product ( array $array )
array_­pro­duct() returns the product of values in an array.
Returns the product as an integer or float.
int array_push ( array &$­array , mixed $value1 [, mixed $... ] )
array_­push() treats array as a stack, and pushes the passed variables onto the end of array. The length of array increases by the number of variables pushed.
Note: If you use array_­push() to add one element to the array it's better to use $array[] = because in that way there is no overhead of calling a function.
Note: array_­push() will raise a warning if the first argument is not an array. This differs from the $var[] behaviour where a new array is created.
Returns the new number of elements in the array.
mixed array_rand ( array $array [, int $num = 1 ] )
Picks one or more random entries out of an array, and returns the key (or keys) of the random entries. It uses a pseudo random number generator that is not suitable for crypto­graphic purposes.
When picking only one entry, array_­rand() returns the key for a random entry. Otherwise, an array of keys for the random entries is returned. This is done so that random keys can be picked from the array as well as random values. Trying to pick more elements than there are in the array will result in an E_WARNING level error, and NULL will be returned.
mixed array_­reduce ( array $array , callable $callback [, mixed $initial = NULL ] )
array_­red­uce() applies iterat­ively the callback function to the elements of the array, so as to reduce the array to a single value.
Returns the resulting value. If the array is empty and initial is not passed, array_­red­uce() returns NULL.
array array_­rep­lac­e_r­ecu­rsive ( array $array1 , array $array2 [, array $... ] )
array_­rep­lac­e_r­ecu­rsive() replaces the values of array1 with the same values from all the following arrays. If a key from the first array exists in the second array, its value will be replaced by the value from the second array. If the key exists in the second array, and not the first, it will be created in the first array. If a key only exists in the first array, it will be left as is. If several arrays are passed for replac­ement, they will be processed in order, the later array overwr­iting the previous values. array_­rep­lac­e_r­ecu­rsive() is recursive : it will recurse into arrays and apply the same process to the inner value. When the value in array1 is scalar, it will be replaced by the value in array2, may it be scalar or array. When the value in array1 and array2 are both arrays, array_­rep­lac­e_r­ecu­rsive() will replace their respective value recurs­ively.
Returns an array, or NULL if an error occurs.
array array_­replace ( array $array1 , array $array2 [, array $... ] )
array_­rep­lace() replaces the values of array1 with values having the same keys in each of the following arrays. If a key from the first array exists in the second array, its value will be replaced by the value from the second array. If the key exists in the second array, and not the first, it will be created in the first array. If a key only exists in the first array, it will be left as is. If several arrays are passed for replac­ement, they will be processed in order, the later arrays overwr­iting the previous values. array_­rep­lace() is not recursive : it will replace values in the first array by whatever type is in the second array.
Returns an array, or NULL if an error occurs.
array array_­reverse ( array $array [, bool $prese­rve­_keys = false ] )
Takes an input array and returns a new array with the order of the elements reversed.
Returns the reversed array.
mixed array_­search ( mixed $needle , array $haystack [, bool $strict = false ] )
Searches haystack for needle.
Returns the key for needle if it is found in the array, FALSE otherwise. If needle is found in haystack more than once, the first matching key is returned. To return the keys for all matching values, use array_­keys() with the optional search­_value parameter instead.
Warning This function may return Boolean FALSE, but may also return a non-Bo­olean value which evaluates to FALSE. Please read the section on Booleans for more inform­ation. Use the === operator for testing the return value of this function.
mixed array_­shift ( array &$­array )
array_­shift() shifts the first value of the array off and returns it, shortening the array by one element and moving everything down. All numerical array keys will be modified to start counting from zero while literal keys won't be touched.
Note: This function will reset() the array pointer of the input array after use.
Returns the shifted value, or NULL if array is empty or is not an array.
array array_­slice ( array $array , int $offset [, int $length = NULL [, bool $prese­rve­_keys = false ]] )
array_­slice() returns the sequence of elements from the array array as specified by the offset and length parame­ters.
Returns the slice. If the offset is larger than the size of the array then returns an empty array.
array array_­splice ( array &$­input , int $offset [, int $length = 0 [, mixed $repla­cement = array() ]] )
Removes the elements designated by offset and length from the input array, and replaces them with the elements of the replac­ement array, if supplied. Note that numeric keys in input are not preserved.
Note: If replac­ement is not an array, it will be typecast to one (i.e. (array) $repla­cem­ent). This may result in unexpected behavior when using an object or NULL replac­ement.
Returns an array consisting of the extracted elements.
number array_sum ( array $array )
array_­sum() returns the sum of values in an array.
Returns the sum of values as an integer or float.
array array_­udi­ff_­assoc ( array $array1 , array $array2 [, array $... ], callable $value­_co­mpa­re_func )
Computes the difference of arrays with additional index check, compares data by a callback function.
Note: Please note that this function only checks one dimension of a n-dime­nsional array. Of course you can check deeper dimensions by using, for example, array_­udi­ff_­ass­oc(­$ar­ray­1[0], $array­2[0], "­som­e_c­omp­ari­son­_fu­nc");.
array_­udi­ff_­assoc() returns an array containing all the values from array1 that are not present in any of the other arguments. Note that the keys are used in the comparison unlike array_­diff() and array_­udi­ff(). The comparison of arrays' data is performed by using an user-s­upplied callback. In this aspect the behaviour is opposite to the behaviour of array_­dif­f_a­ssoc() which uses internal function for compar­ison.
array array_­udi­ff_­uassoc ( array $array1 , array $array2 [, array $... ], callable $value­_co­mpa­re_func , callable $key_c­omp­are­_func )
Computes the difference of arrays with additional index check, compares data and indexes by a callback function. Note that the keys are used in the comparison unlike array_­diff() and array_­udi­ff().
Returns an array containing all the values from array1 that are not present in any of the other arguments.
array array_­udiff ( array $array1 , array $array2 [, array $... ], callable $value­_co­mpa­re_func )
Computes the difference of arrays by using a callback function for data compar­ison. This is unlike array_­diff() which uses an internal function for comparing the data.
Returns an array containing all the values of array1 that are not present in any of the other arguments.
array array_­uin­ter­sec­t_assoc ( array $array1 , array $array2 [, array $... ], callable $value­_co­mpa­re_func )
Computes the inters­ection of arrays with additional index check, compares data by a callback function. Note that the keys are used in the comparison unlike in array_­uin­ter­sect(). The data is compared by using a callback function.
Returns an array containing all the values of array1 that are present in all the arguments.
array array_­uin­ter­sec­t_u­assoc ( array $array1 , array $array2 [, array $... ], callable $value­_co­mpa­re_func , callable $key_c­omp­are­_func )
Computes the inters­ection of arrays with additional index check, compares data and indexes by separate callback functions.
Returns an array containing all the values of array1 that are present in all the arguments.
array array_­uin­tersect ( array $array1 , array $array2 [, array $... ], callable $value­_co­mpa­re_func )
Computes the inters­ection of arrays, compares data by a callback function.
Returns an array containing all the values of array1 that are present in all the arguments.
array array_­unique ( array $array [, int $sort_­flags = SORT_S­TRING ] )
Takes an input array and returns a new array without duplicate values. Note that keys are preserved. array_­uni­que() sorts the values treated as string at first, then will keep the first key encoun­tered for every value, and ignore all following keys. It does not mean that the key of the first related value from the unsorted array will be kept.
Note: Two elements are considered equal if and only if (string) $elem1 === (string) $elem2 i.e. when the string repres­ent­ation is the same, the first element will be used.
Returns the filtered array.
int array_­unshift ( array &$­array , mixed $value1 [, mixed $... ] )
array_­uns­hift() prepends passed elements to the front of the array. Note that the list of elements is prepended as a whole, so that the prepended elements stay in the same order. All numerical array keys will be modified to start counting from zero while literal keys won't be touched.
Returns the new number of elements in the array.
array array_­values ( array $array )
array_­val­ues() returns all the values from the array and indexes the array numeri­cally.
Returns an indexed array of values.
bool array_­wal­k_r­ecu­rsive ( array &$­array , callable $callback [, mixed $userdata = NULL ] )
Applies the user-d­efined callback function to each element of the array. This function will recurse into deeper arrays.
Returns TRUE on success or FALSE on failure.
bool array_walk ( array &$­array , callable $callback [, mixed $userdata = NULL ] )
Applies the user-d­efined callback function to each element of the array array. array_­walk() is not affected by the internal array pointer of array. array_­walk() will walk through the entire array regardless of pointer position.
Returns TRUE on success or FALSE on failure.
If function callback requires more parameters than given to it, an error of level E_WARNING will be generated each time array_­walk() calls callback.
array array ([ mixed $... ] )
Creates an array. Read the section on the array type for more inform­ation on what an array is.
Returns an array of the parame­ters. The parameters can be given an index with the => operator. Read the section on the array type for more inform­ation on what an array is.
bool arsort ( array &$­array [, int $sort_­flags = SORT_R­EGULAR ] )
This function sorts an array such that array indices maintain their correl­ation with the array elements they are associated with. This is used mainly when sorting associ­ative arrays where the actual element order is signif­icant.
Note: If two members compare as equal, their relative order in the sorted array is undefined.
Returns TRUE on success or FALSE on failure.
bool asort ( array &$­array [, int $sort_­flags = SORT_R­EGULAR ] )
This function sorts an array such that array indices maintain their correl­ation with the array elements they are associated with. This is used mainly when sorting associ­ative arrays where the actual element order is significant.
Note: If two members compare as equal, their relative order in the sorted array is undefined.
Returns TRUE on success or FALSE on failure.
array compact ( mixed $varname1 [, mixed $... ] )
Creates an array containing variables and their values. For each of these, compact() looks for a variable with that name in the current symbol table and adds it to the output array such that the variable name becomes the key and the contents of the variable become the value for that key. In short, it does the opposite of extract(). Any strings that are not set will simply be skipped.
Returns the output array with all the variables added to it.
int count ( mixed $array­_or­_co­untable [, int $mode = COUNT_­NORMAL ] )
Counts all elements in an array, or something in an object. For objects, if you have SPL installed, you can hook into count() by implem­enting interface Countable. The interface has exactly one method, Counta­ble­::c­ount(), which returns the return value for the count() function. Please see the Array section of the manual for a detailed explan­ation of how arrays are implem­ented and used in PHP.
Returns the number of elements in array_­or_­cou­ntable. If the parameter is not an array or not an object with implem­ented Countable interface, 1 will be returned. There is one exception, if array_­or_­cou­ntable is NULL, 0 will be returned.
Caution count() may return 0 for a variable that isn't set, but it may also return 0 for a variable that has been initia­lized with an empty array. Use isset() to test if a variable is set.
mixed current ( array &$­array )
Every array has an internal pointer to its "­cur­ren­t" element, which is initia­lized to the first element inserted into the array.
The current() function simply returns the value of the array element that's currently being pointed to by the internal pointer. It does not move the pointer in any way. If the internal pointer points beyond the end of the elements list or the array is empty, current() returns FALSE.
Warning This function may return Boolean FALSE, but may also return a non-Bo­olean value which evaluates to FALSE. Please read the section on Booleans for more inform­ation. Use the === operator for testing the return value of this function.
array each ( array &$­array )
Return the current key and value pair from an array and advance the array cursor. After each() has executed, the array cursor will be left on the next element of the array, or past the last element if it hits the end of the array. You have to use reset() if you want to traverse the array again using each.
Returns the current key and value pair from the array array. This pair is returned in a four-e­lement array, with the keys 0, 1, key, and value. Elements 0 and key contain the key name of the array element, and 1 and value contain the data. If the internal pointer for the array points past the end of the array contents, each() returns FALSE.
mixed end ( array &$­array )
end() advances array's internal pointer to the last element, and returns its value.
Returns the value of the last element or FALSE for empty array.
int extract ( array &$­array [, int $flags = EXTR_O­VER­WRITE [, string $prefix = NULL ]] )
Import variables from an array into the current symbol table. Checks each key to see whether it has a valid variable name. It also checks for collisions with existing variables in the symbol table.
Returns the number of variables succes­sfully imported into the symbol table.
bool in_array ( mixed $needle , array $haystack [, bool $strict = FALSE ] )
Searches haystack for needle using loose comparison unless strict is set.
Returns TRUE if needle is found in the array, FALSE otherwise.
key_exists
This function is an alias of: array_­key­_ex­ists().
mixed key ( array &$­array )
key() returns the index element of the current array position.
The key() function simply returns the key of the array element that's currently being pointed to by the internal pointer. It does not move the pointer in any way. If the internal pointer points beyond the end of the elements list or the array is empty, key() returns NULL.
bool krsort ( array &$­array [, int $sort_­flags = SORT_R­EGULAR ] )
Sorts an array by key in reverse order, mainta­ining key to data correl­ations. This is useful mainly for associ­ative arrays.
Returns TRUE on success or FALSE on failure.
bool ksort ( array &$­array [, int $sort_­flags = SORT_R­EGULAR ] )
Sorts an array by key, mainta­ining key to data correl­ations. This is useful mainly for associ­ative arrays.
Returns TRUE on success or FALSE on failure.
array list ( mixed $var1 [, mixed $... ] )
Like array(), this is not really a function, but a language construct. list() is used to assign a list of variables in one operation.
Note: list() only works on numerical arrays and assumes the numerical indices start at 0.
Warning In PHP 5, list() assigns the values starting with the right-most parameter.
Warning Modifi­cation of the array during list() execution (e.g. using list($a, $b) = $b) results in undefined behavior.
Returns the assigned array.
bool natcas­esort ( array &$­array )
natcas­esort() is a case insens­itive version of natsort(). This function implements a sort algorithm that orders alphan­umeric strings in the way a human being would while mainta­ining key/value associ­ations. This is described as a "­natural orderi­ng".
Note: If two members compare as equal, their relative order in the sorted array is undefined.
Returns TRUE on success or FALSE on failure.
bool natsort ( array &$­array )
This function implements a sort algorithm that orders alphan­umeric strings in the way a human being would while mainta­ining key/value associ­ations. This is described as a "­natural orderi­ng". An example of the difference between this algorithm and the regular computer string sorting algorithms (used in sort()) can be seen in the example below.
Note: If two members compare as equal, their relative order in the sorted array is undefined.
Returns TRUE on success or FALSE on failure.
mixed next ( array &$­array )
next() behaves like current(), with one differ­ence. It advances the internal array pointer one place forward before returning the element value. That means it returns the next array value and advances the internal array pointer by one.
Returns the array value in the next place that's pointed to by the internal array pointer, or FALSE if there are no more elements.
Warning This function may return Boolean FALSE, but may also return a non-Bo­olean value which evaluates to FALSE. Please read the section on Booleans for more inform­ation. Use the === operator for testing the return value of this function.
pos
This function is an alias of: current()
mixed prev ( array &$­array )
Rewind the internal array pointer. prev() behaves just like next(), except it rewinds the internal array pointer one place instead of advancing it.
Note: You won't be able to distin­guish the beginning of an array from a boolean FALSE element. To properly traverse an array which may contain FALSE elements, see the each() function.
Returns the array value in the previous place that's pointed to by the internal array pointer, or FALSE if there are no more elements.
Warning This function may return Boolean FALSE, but may also return a non-Bo­olean value which evaluates to FALSE. Please read the section on Booleans for more inform­ation. Use the === operator for testing the return value of this function.
array range ( mixed $start , mixed $end [, number $step = 1 ] )
Create an array containing a range of elements.
Returns an array of elements from start to end, inclusive.
mixed reset ( array &$­array )
reset() rewinds array's internal pointer to the first element and returns the value of the first array element.
Returns the value of the first array element, or FALSE if the array is empty.
bool rsort ( array &$­array [, int $sort_­flags = SORT_R­EGULAR ] )
This function sorts an array in reverse order (highest to lowest).
Note: If two members compare as equal, their relative order in the sorted array is undefined.
Returns TRUE on success or FALSE on failure.
bool shuffle ( array &$­array )
This function shuffles (rando­mizes the order of the elements in) an array. It uses a pseudo random number generator that is not suitable for crypto­graphic purposes.
Note: If two members compare as equal, their relative order in the sorted array is undefined.
Note: This function assigns new keys to the elements in array. It will remove any existing keys that may have been assigned, rather than just reordering the keys.
Returns TRUE on success or FALSE on failure.
sizeof
This function is an alias of: count().
bool sort ( array &$­array [, int $sort_­flags = SORT_R­EGULAR ] )
This function sorts an array. Elements will be arranged from lowest to highest when this function has completed.
Note: If two members compare as equal, their relative order in the sorted array is undefined.
Returns TRUE on success or FALSE on failure.
bool uasort ( array &$­array , callable $value­_co­mpa­re_func )
This function sorts an array such that array indices maintain their correl­ation with the array elements they are associated with, using a user-d­efined comparison function. This is used mainly when sorting associ­ative arrays where the actual element order is significant.
Note: If two members compare as equal, their relative order in the sorted array is undefined.
Returns TRUE on success or FALSE on failure.
bool uksort ( array &$­array , callable $key_c­omp­are­_func )
uksort() will sort the keys of an array using a user-s­upplied comparison function. If the array you wish to sort needs to be sorted by some non-tr­ivial criteria, you should use this function.
Note: If two members compare as equal, their relative order in the sorted array is undefined.
Returns TRUE on success or FALSE on failure.
bool usort ( array &$­array , callable $value­_co­mpa­re_func )
This function will sort an array by its values using a user-s­upplied comparison function. If the array you wish to sort needs to be sorted by some non-tr­ivial criteria, you should use this function.
Note: If two members compare as equal, their relative order in the sorted array is undefined.
Note: This function assigns new keys to the elements in array. It will remove any existing keys that may have been assigned, rather than just reordering the keys.
Returns TRUE on success or FALSE on failure.

Array constants

ARRAY_­FIL­TER­_US­E_KEY
pass key as the only argument to callback instead of the value
ARRAY_­FIL­TER­_US­E_BOTH
pass both value and key as arguments to callback instead of the value
SORT_R­EGULAR
compare items normally (don't change types)
SORT_N­UMERIC
compare items numeri­cally
SORT_S­TRING
compare items as strings
SORT_L­OCA­LE_­STRING
compare items as strings, based on the current locale. It uses the locale, which can be changed using setloc­ale()
SORT_N­ATURAL
compare items as strings using "­natural orderi­ng" like natsort()
SORT_F­LAG­_CASE
can be combined (bitwise OR) with SORT_S­TRING or SORT_N­ATURAL to sort strings case-i­nse­nsi­tively
EXTR_O­VER­WRITE
If there is a collision, overwrite the existing variable.
EXTR_SKIP
If there is a collision, don't overwrite the existing variable.
EXTR_P­REF­IX_SAME
If there is a collision, prefix the variable name with prefix.
EXTR_P­REF­IX_ALL
Prefix all variable names with prefix.
EXTR_P­REF­IX_­INVALID
Only prefix invali­d/n­umeric variable names with prefix.
EXTR_I­F_E­XISTS
Only overwrite the variable if it already exists in the current symbol table, otherwise do nothing. This is useful for defining a list of valid variables and then extracting only those variables you have defined out of $_REQUEST, for example.
EXTR_P­REF­IX_­IF_­EXISTS
Only create prefixed variable names if the non-pr­efixed version of the same variable exists in the current symbol table.
EXTR_REFS
Extracts variables as refere­nces. This effect­ively means that the values of the imported variables are still refere­ncing the values of the array parameter. You can use this flag on its own or combine it with any other flag by OR'ing the flags.

Filesystem Functions

string basename ( string $path [, string $suffix ] )
Given a string containing the path to a file or directory, this function will return the trailing name component.
Returns the base name of the given path.
bool chgrp ( string $filename , mixed $group )
Attempts to change the group of the file filename to group. Only the superuser may change the group of a file arbitr­arily; other users may change the group of a file to any group of which that user is a member.
Returns TRUE on success or FALSE on failure.
bool chmod ( string $filename , int $mode )
Attempts to change the mode of the specified file to that given in mode.
Returns TRUE on success or FALSE on failure.
bool chown ( string $filename , mixed $user )
Attempts to change the owner of the file filename to user user. Only the superuser may change the owner of a file.
Returns TRUE on success or FALSE on failure.
void clears­tat­cache ([ bool $clear­_re­alp­ath­_cache = false [, string $filename ]] )
When you use stat(), lstat(), or any of the other functions listed in the affected functions list (below), PHP caches the inform­ation those functions return in order to provide faster perfor­mance. However, in certain cases, you may want to clear the cached inform­ation. For instance, if the same file is being checked multiple times within a single script, and that file is in danger of being removed or changed during that script's operation, you may elect to clear the status cache. In these cases, you can use the clears­tat­cache() function to clear the inform­ation that PHP caches about a file. You should also note that PHP doesn't cache inform­ation about non-ex­istent files. So, if you call file_e­xists() on a file that doesn't exist, it will return FALSE until you create the file. If you create the file, it will return TRUE even if you then delete the file. However unlink() clears the cache automatically.
Note: This function caches inform­ation about specific filenames, so you only need to call clears­tat­cache() if you are performing multiple operations on the same filename and require the inform­ation about that particular file to not be cached.
No value is returned.
bool copy ( string $source , string $dest [, resource $context ] )
Makes a copy of the file source to dest. If you wish to move a file, use the rename() function.
Returns TRUE on success or FALSE on failure.
delete
This is a dummy manual entry to satisfy those people who are looking for unlink() or unset() in the wrong place.
string dirname ( string $path [, int $levels = 1 ] )
Given a string containing the path of a file or directory, this function will return the parent direct­ory's path that is levels up from the current directory.
Returns the path of a parent directory. If there are no slashes in path, a dot ('.') is returned, indicating the current directory. Otherwise, the returned string is path with any trailing /component removed.
float disk_f­ree­_space ( string $directory )
Given a string containing a directory, this function will return the number of bytes available on the corres­ponding filesystem or disk partition.
Returns the number of available bytes as a float or FALSE on failure.
float disk_t­ota­l_space ( string $directory )
Given a string containing a directory, this function will return the total number of bytes on the corres­ponding filesystem or disk partition.
Returns the total number of bytes as a float or FALSE on failure.
diskfr­eespace
This function is an alias of: disk_f­ree­_sp­ace().
bool fclose ( resource $handle )
The file pointed to by handle is closed.
Returns TRUE on success or FALSE on failure.
bool feof ( resource $handle )
Tests for end-of­-file on a file pointer.
Returns TRUE if the file pointer is at EOF or an error occurs (including socket timeout); otherwise returns FALSE.
bool fflush ( resource $handle )
This function forces a write of all buffered output to the resource pointed to by the file handle.
Returns TRUE on success or FALSE on failure.
string fgetc ( resource $handle )
Gets a character from the given file pointer.
Returns a string containing a single character read from the file pointed to by handle. Returns FALSE on EOF.
Warning This function may return Boolean FALSE, but may also return a non-Bo­olean value which evaluates to FALSE. Please read the section on Booleans for more inform­ation. Use the === operator for testing the return value of this function.
array fgetcsv ( resource $handle [, int $length = 0 [, string $delimiter = "­," [, string $enclosure = '"' [, string $escape = "­\" ]]]] )
Similar to fgets() except that fgetcsv() parses the line it reads for fields in CSV format and returns an array containing the fields read.
Returns an indexed array containing the fields read.
Note: A blank line in a CSV file will be returned as an array comprising a single null field, and will not be treated as an error.
Note: If PHP is not properly recogn­izing the line endings when reading files either on or created by a Macintosh computer, enabling the auto_d­ete­ct_­lin­e_e­ndings run-time config­uration option may help resolve the problem.
fgetcsv() returns NULL if an invalid handle is supplied or FALSE on other errors, including end of file.
string fgets ( resource $handle [, int $length ] )
Gets a line from file pointer.
Returns a string of up to length - 1 bytes read from the file pointed to by handle. If there is no more data to read in the file pointer, then FALSE is returned. If an error occurs, FALSE is returned.
string fgetss ( resource $handle [, int $length [, string $allow­abl­e_tags ]] )
Identical to fgets(), except that fgetss() attempts to strip any NUL bytes, HTML and PHP tags from the text it reads.
Returns a string of up to length - 1 bytes read from the file pointed to by handle, with all HTML and PHP code stripped. If an error occurs, returns FALSE.
bool file_e­xists ( string $filename )
Checks whether a file or directory exists.
Returns TRUE if the file or directory specified by filename exists; FALSE otherwise.
Note: This function will return FALSE for symlinks pointing to non-ex­isting files.
string file_g­et_­con­tents ( string $filename [, bool $use_i­ncl­ude­_path = false [, resource $context [, int $offset = 0 [, int $maxlen ]]]] )
This function is similar to file(), except that file_g­et_­con­tents() returns the file in a string, starting at the specified offset up to maxlen bytes. On failure, file_g­et_­con­tents() will return FALSE. file_g­et_­con­tents() is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance.
Note: If you're opening a URI with special charac­ters, such as spaces, you need to encode the URI with urlenc­ode().
The function returns the read data or FALSE on failure.
Warning This function may return Boolean FALSE, but may also return a non-Bo­olean value which evaluates to FALSE. Please read the section on Booleans for more inform­ation. Use the === operator for testing the return value of this function.
An E_WARNING level error is generated if filename cannot be found, maxlength is less than zero, or if seeking to the specified offset in the stream fails.
int file_p­ut_­con­tents ( string $filename , mixed $data [, int $flags = 0 [, resource $context ]] )
This function is identical to calling fopen(), fwrite() and fclose() succes­sively to write data to a file. If filename does not exist, the file is created. Otherwise, the existing file is overwr­itten, unless the FILE_A­PPEND flag is set.
This function returns the number of bytes that were written to the file, or FALSE on failure.
Warning This function may return Boolean FALSE, but may also return a non-Bo­olean value which evaluates to FALSE. Please read the section on Booleans for more inform­ation. Use the === operator for testing the return value of this function.