HOW THE QUIZ WORKS:
Clicking the ‘randomize’ button situated above the reference table generates a new table whereby the function descriptions, function syntaxes, and function return values are randomized. The quiz involves matching the function descriptions, function syntaxes, and function return values to the correct function name. Information relating to the randomization of table cells will be displayed for three seconds, before disappearing.
On a desktop computer, table elements are selected by left-clicking the desired table cell and holding the left click in the mouse down position for one second before releasing the left click. The text inside the table cell will turn red to indicate that the one-second mouse left-click has successfully selected a table cell. To then swap the selected table cell with the target table cell, simply repeat the one-second left mouse-click process on the target cell; the table cells will swap position. To de-select a table cell, simply repeat the one-second left mouse-click process on the original table cell.
To select a table element on a touchscreen device (mobile, tablet), simply touch the desired table cell and maintain the touch for one second before removing your finger from the screen. The text inside the table cell will turn red to indicate that the one-second touch has successfully selected a table cell. To then swap the selected table cell with the target table cell, simply repeat the one-second touch process on the target cell; the table cells will swap position. To de-select a table cell, simply repeat the one-second touch process on the original table cell.
Normal touchscreen scrolling behaviour is exhibited by the cells with a light green background; cells without a light green background will not respond to normal touchscreen scrolling. The table is positioned in such a way that the user can also initiate touchscreen scrolling by swiping to the right or left of the table.
When a row consists of the correct function name, function description, function syntax, and function return value, the background colour of the row will change from ‘transparent’ to ‘khaki’; this provides visual feedback that the row is complete.
Once the entire table is complete, a paragraph of feedback will congratulate the user and provide the following information: date and time of quiz commencement; date and time of quiz completion; and the length of time it took the user to complete the quiz.
VIEWPORT OPTIONS:



PURPOSE:
This webpage serves two purposes:
- It provides a reference table for the PHP array functions, with information extracted and condensed from w3schools.com and php.net.
- It enables users to complete a quiz related to the PHP array functions.
USAGE:
For each array function there are four table cells of information: the function name; the function description; the function syntax; and the function return value. There are three layouts available – ‘mobile‘, ‘tablet‘, and ‘desktop‘.
Click the relevant button below to display the PHP array functions reference table, sized appropriately for the desired viewport. A ‘RANDOMIZE‘ button appears above the reference table once the viewport is selected; clicking this button facilitates the commencement of a quiz.
Click the ‘RANDOMIZE‘ button to randomize the functional descriptions, the functional syntaxes, and the functional return information.
FUNCTION NAME | FUNCTION DESCRIPTION | FUNCTION SYNTAX | FUNCTION RETURN VALUE |
---|---|---|---|
array()
[Create an array] |
Creates an array. PHP arrays can have numeric indices [‘indexed arrays’], named keys [‘associative arrays’], or contain one or more other arrays [‘multidimensional arrays’]. | [1. indexed arrays:]array(value1, value2, value3 etc);
[2. associative arrays:] |
Returns an array of the parameters. |
array_change_key_case()
[Changes the case of all keys in an array] |
Returns an array with all non-numeric keys either uppercased or lowercased, depending on the parameter. | EITHER:array_change_key_case(array); OR: array_change_key_case(array, case); [case – either CASE_UPPER or CASE_LOWER [default]] |
Returns an array with its keys uppercased or lowercased. If array is not an array, this function returns false. |
array_chunk()
[Split an array into chunks] |
Chunks array into arrays with size elements. The last chunk can have fewer than size elements. | array_chunk(array, size, preserve_keys);
[preserve_keys is an optional parameter, with a default value of false, specifying whether the original keys are retained in the returned array.] |
Returns a multidimensional array with numeric indices, with each dimension containing size elements. NULL will be returned if size is less than 1 and E_WARNING will be thrown. |
array_column()
[Return the values from a single column in the input array] |
Returns the values from a single column of the input_array. | array_column(input_array, column_key, index_key);
[index_key is an optional parameter, specifying the column to use as the index/keys for the returned array.] |
Returns an array of values representing a single column from the input array. |
array_combine()
[Creates an array by using one array for keys and another for its values] |
Creates an array by combining the values from the keys array [used as keys] with the values from the values array [used as values]. | array_combine(keys, values); |
Returns the combined array, or FALSE with an E_WARNING if the number of elements in the values and keys arrays don’t match. |
array_count_values()
[Counts all the values of an array] |
Returns an array using the values of array as keys and their frequency [‘count’] in array as values. | array_count_values(array); |
Returns an associative array of values from array as keys and their count as value. An E_WARNING is thrown for every element which is neither a string nor an integer. |
array_diff_assoc()
[Computes the difference of arrays with additional index check] |
Compares array1 against array2 and returns the differences, also using the array keys in the comparison. | array_diff_assoc(array1, array2); [two arrays are required for the comparison, but more can, optionally, be used] |
array_diff_assoc() : returns an array containing all the values in array1 that are not present in any of the other arrays. |
array_diff_key()
[Computes the difference of arrays, using keys for comparison] |
Compares the keys from array1 against the keys from array2 and returns the differences. | array_diff_key(array1, array2, array3 etc);
[two arrays are required for the comparison, but more can, optionally, be used] |
array_diff_key() : returns an array containing all the entries from array1 whose keys are absent from all of the other arrays. |
array_diff_uassoc()
[Computes the difference of arrays with additional index check which is performed by a user-supplied callback function] |
Compares array1 against array2 and returns the difference. Both keys and values are compared. Keys are compared via user-supplied callable_key_comparison_function. | array_diff_uassoc(array1, array2, array3..., callable_key_comparison_function);
[two arrays are required for the comparison, but more can, optionally, be used |
array_diff_uassoc() : returns an array containing all the entries in array1 that are not present in the comparison arrays, when both keys and values are compared. |
array_diff_ukey()
[Computes the difference between arrays using a callback function on the keys for comparison] |
Compares the keys from array1 against the keys from array2 using a user-supplied comparison function, and returns the differences. | array_diff_ukey()(array1, array2, array3 etc, callable_key_comparison_function);
[two arrays are required for the comparison, but more can, optionally, be used |
array_diff_ukey() : returns an array containing all the entries from array1 that are not present in any of the other arrays, when keys are compared. |
array_diff()
[Computes the difference of arrays] |
Compares the values of array1 against the values of one or more comparison arrays, returning the values in array1 that are not present in any of the comparison arrays. | array_diff(array1, array2, array3 etc);
[two arrays are required for the comparison, but more can, optionally, be used] |
array_diff() : returns an array containing all the entries from array1 that are not present in the comparison arrays, after value-based comparison has occurred. |
array_fill_keys()
[Fill an array with values, specifying keys] |
Fills an array with value, using the value of the keys array as keys. | array_fill_keys(keys, value);
[Illegal key values will be converted to string.] |
Returns the filled array. |
array_fill()
[Fill an array with values] |
Fills an array with number entries of value, keys starting at index. | array_fill(index, number, value);
[if index is negative, the first index of the returned array will be index and the following indices will start from zero.] |
As with array_fill_keys() , the filled array is returned. |
array_filter()
[Filters elements of an array using a callback function] |
Moves sequentially through each value in array, filtering them through callback_function. The current value from array is returned into the result array if callback_function returns true. Array keys are preserved. | array_filter(array, callback_function, flag);
[Only the array parameter is required. If callback_function is not supplied, all values of array equating to |
Returns the filtered array. |
array_flip()
[Exchanges all keys with their associated values in an array] |
Returns an array in flip order: values from array become keys and keys from array become values. The values of array need to be either integer or string – i.e. valid array keys; invalid key/value pairs will not be included in the result. | array_flip(array); |
Returns the flipped array on success, and NULL on failure. If a value has several occurences, the latest key will be used as its value (all others will be lost). |
array_intersect_assoc()
[Computes the intersection of arrays with additional index check] |
Compares the keys and values of array1 with all subsequent arrays, returning an array of keys and values that are present in all the arrays. | array_intersect_assoc(array1, array2, array3...);
[Only two arrays are required.] |
array_intersect_assoc() : returns an associative array containing all the values in array1 that are present in all the other arrays. |
array_intersect_key()
[Computes the intersection of arrays using keys for comparison] |
Compares the keys of array1 with those of subsequent arrays, returning an array containing the entries of array1 that have keys present in all subsequent arrays. | array_intersect_key(array1, array2, array3...);
[Only two arrays are required.] |
array_intersect_key() : returns an associative array whose keys are present in all arrays. |
array_intersect_uassoc()
[Computes the intersection of arrays with additional index check, compares indexes by a callback function] |
Compares the keys and values of array1 with all subsequent arrays by means of a user-defined callback_function, returning an array that contains the matches. | array_intersect_uassoc(array1, array2, array3..., callback_function); |
array_intersect_uassoc() : returns an associative array containing the entries in array1 that are present in all subsequent arrays. |
array_intersect_ukey()
[Computes the intersection of arrays using a callback function on the keys for comparison] |
Uses callback_function to compare the keys of two or more arrays, returning an array of entries whose key is present in array1 and all subsequent arrays. | array_intersect_ukey(array1, array2, array3..., callback_function); |
array_intersect_ukey() : returns an array containing the values of array1 whose keys exist in all the compared arrays. |
array_intersect()
[Computes the intersection of arrays] |
Compares the values of array1 against those of subsequent arrays, returning an array of those values in array1 that are present in all the arrays. | array_intersect(array1, array2, array3...); |
array_intersect() : returns an array of all the values in array1 whose values exist in all comparison arrays. |
array_key_exists()
[Checks if the given key or index exists in the array] |
Checks if key exists in the array. Alias of key_exists() . |
array_key_exists(key, array);
[key search occurs in the first dimension only.] |
Boolean return value: TRUE on success, FALSE on failure. |
array_keys()
[Return all the keys or a subset of the keys of an array] |
If search_value is specified then only the keys for that value are returned. Otherwise, all keys from array are returned. | array_keys(array, search_value [optional], strict_equality [optional; default = false]); |
Returns an array of all the relevant keys in array. |
array_map()
[Applies the callback to the elements of the given arrays] |
Iterates over the elements of array1 and any other arrays passed to the callback_function, returning an array of callback_function-applied [‘mapped’] elements. | array_map(callback_function, array1, array2...);
[The number of parameters that callback_function accepts should match the number of arrays passed to |
Returns an array of post-callback_function [‘mapped’] elements. |
array_merge_recursive()
[Merge two or more arrays recursively] |
Merges the values of one or more arrays together; the values of one are appended to the other. In the case of identical keys in the input arrays, the values for these keys are merged recursively. Where arrays have the same numeric key, the latter one will be appended. | array_merge_recursive(array1, array2...); |
An array of values obtained by merging the arrays together recursively. |
array_merge()
[Merge one or more arrays] |
Appends the values of one array to the previous one, returning the resultant merged array. A later value for the same string key will overwrite the previous one. A later value for the same numeric key will be appended. Numeric keys in the input array will be renumbered, with incrementing keys starting from 0 in the resultant array. | array_merge()(array1, array2...); |
Returns the resultant merged array. |
array_multisort()
[Sort multiple or multi-dimensional arrays] |
Used to sort multiple arrays at once, or a multi-dimensional array by one or more dimensions. String keys will be preserved, whereas numeric keys will be re-indexed. If two members compare as equal their relative order in the sorted array is undefined. | array_multisort(array1, array1_sort_order, array1_sort_flags, array2...);
[array1_sort_order: |
array_multisort() : Boolean return value – TRUE on success, FALSE on failure. |
array_pad()
[Pad array to the specified length with a value] |
Produces a copy of array padded to size with value. If size is positive then the array is padded to the right; if size is negative then the array is padded on the left. If the absolute value of size is less than or equal to the length of array then no padding takes place. A maximum of 1,048,576 elements can be added at a time. | array_pad(array, size, value); |
Returns a copy of array padded to size with value. |
array_pop()
[Pop the element off the end of array] |
Pops and returns the last value of array, shortening array by one element. | array_pop(array);
[This function rewinds array‘s internal pointer after use.] |
Returns the last element of array, provided that array is not empty. If array is empty or is not an array, NULL is returned. An E-WARNING -level error is emitted when the function is called on a non-array. |
array_product()
[Calculate the product of values in an array] |
Returns the product of values in array. | array_product(array); |
Returns the product as an integer or float. The product for an empty array is now 1, rather than 0. |
array_push()
[Push one or more elements on to the end of array] |
Pushes the passed variables on to the end of array. Increases the length of array by the number of variables passed. | array_push(array, variables [optional]); |
Returns the new number of elements in the array. |
array_rand()
[Pick one or more random keys out of an array] |
Picks one or more random entries out of an array, returning the key(s) of the random entries. It uses a pseudo random number generator unsuitable for cryptographic purposes. | array_rand(array, number [optional – specifies how many entries should be picked]); |
When picking only one entry, the key for a random entry is returned. Otherwise an array of keys for the random entries is returned. If number exceeds the amount of elements in array, an E_WARNING -level error is emitted and NULL is returned. |
array_reduce()
[Iteratively reduce the array to a single value using a callback function] |
Iteratively applies callback_function to the elements of array, so as to reduce the array to a single value. | array_reduce(array, callback_function, initial [optional parameter, used at the beginning of the process, or as a final result in case the array is empty]);
[callback_function has the following syntax: |
Returns the resulting, reduced value. Returns NULL when array is empty and initial is not passed. |
array_replace_recursive()
[Replaces elements from passed arrays into the first array recursively] |
Replaces the values of array1 with the values of elements with the same keys from all the subsequent arrays. If a key in array1 exists in array2, its value will be replaced by the value in array2. If a key exists in array2 and not in array1, it will be created in array1. If a key only exists in array1 it will be left as it is. If several arrays are passed for replacement they will be processed sequentially, with the later array overwriting previous values. This function will recurse into arrays, applying the same process to the inner value. When the value in array1 is scalar, it will be replaced by the value in array2 regardless of whether that value is scalar or of the array type. | array_replace_recursive(array1, array2, array3 [optional]…); |
Returns the recursively-replaced array, or NULL if an error occurs. |
array_replace()
[Replaces elements from passed arrays into the first array] |
Replaces the values of array1 with values having the same keys in each of the following arrays. If a key in array1 exists in array2, its value will be replaced by the value in array2. If a key exists in array2 and not in array1, it will be created in array1. If a key only exists in array1 it will be left as it is. If several arrays are passed for replacement they will be processed sequentially, with the later array overwriting previous values. | array_replace(array1, array2, array3 [optional parameter]…); |
Returns the replaced array, or NULL if an error occurs. |
array_reverse()
[Return an array with elements in reverse order] |
Takes an input array and returns a new array with the order of the elements reversed. | array_reverse(array, preserve_keys [optional boolean parameter]);
[If preserve_keys is set to |
Returns the reversed array. |
array_search()
[Searches an array for a given value and returns the first corresponding key if successful] |
Searches array for value. If value is a string, the comparison is done in a case-sensitive manner. | array_search(value, array, strict [optional boolean parameter]);
[strict specifies whether to search for identical values in the array] |
Searches for, and returns, the first key for value; if value is not present, NULL is returned. |
array_shift()
[Shift an element off the beginning of array] |
Shifts the first value of array off and returns it, shortening the array by one element and moving everything down. Numerical array keys will be modified to start counting from zero, while literal keys will remain untouched. | array_shift(array);
[This function rewinds array‘s internal pointer after use.] |
Returns the shifted value on success; NULL if array is empty or is not an array. |
array_slice()
[Extract a slice of the array] |
Returns the sequence of elements [‘slice’] from array as specified by the offset and length parameters. | array_slice(array, offset, length [optional], preserve_keys [optional]);
[If offset is non-negative, the sequence starts at offset in array; otherwise, the sequence starts that far from the end of array. |
Returns the specified array slice. An empty array is returned when offset is larger than the size of array. |
array_splice()
[Remove a portion of the array and replace it with something else] |
Removes the elements designated by offset and length from array, replacing them with the elements of replacement_array, if supplied [creating a spliced array]. Numeric keys in array are not preserved. If replacement_array is not an array it will be typecast to one. | array_splice(array, offset, length [optional parameter], replacement_array [optional parameter]);
[If offset is positive, the start of the removed portion is at offset from the beginning of array. If negative then it starts at that offset from the end of array. |
Returns an array consisting of the extracted [‘spliced’] elements. |
array_sum
[Calculate the sum of values in an array] |
Returns the sum of values in an array. | array_sum(array); |
Returns the sum of values as an integer or float, or zero if array is empty. |
array_udiff_assoc()
[Computes the difference of arrays with additional index check, compares data by a callback function] |
Computes the difference of arrays with additional index check, compares data by callback_function. | array_udiff_assoc(array1, array2, array3 [optional parameter]…, callback_function);
[callback_function must return an integer that is less than, equal to, or greater than 0 if the first argument is considered to be respectively less than, equal to, or greater than the second argument.] |
array_udiff_assoc() : returns an array containing all the values in array1 that are not present in any of the comparison arguments. The comparison of arrays’ data is performed via a user-supplied callback_function. |
array_udiff_uassoc()
[Computes the difference of arrays with additional index check, compares data and indexes by a callback function] |
Computes the difference of arrays with additional index check, compares data and indexes by a callback_function [value_compare, key_compare]. | array_udiff_uassoc(array1, array2, array3 [optional parameter]…, value_compare, key_compare);
[value_compare and key_compare must return an integer less than, equal to, or greater than zero, depending on whether the first argument is considered to be respectively less than, equal to, or greater than the second argument.] |
array_udiff_uassoc() : returns an array of all the values in array1 that are not present in any subsequent array. |
array_udiff()
[Computes the difference of arrays by using a callback function for data comparison] |
Computes the difference in arrays by using callback_function for data comparison. | array_udiff(array1, array2, array3... [optional parameter], callback_function);
[callback_function must return an integer less than, equal to, or greater than 0, depending on whether the first argument is respectively less than, equal to, or greater than the second.] |
array_udiff() : returns an array containing all the values in array1 that are not present in any of the other arguments. |
array_uintersect_assoc()
[Computes the intersection of arrays with additional index check, compares data by a callback function] |
Computes the intersection of arrays with additional index check, comparing data via callback_function. | array_uintersect_assoc(array1, array2, array3 [optional parameter]..., callback_function);
[callback_function must return an integer that is less than, equal to, or greater than zero, depending on whether the first value is considered to be respectively less than, equal to, or greater than the second argument.] |
array_uintersect_assoc() : returns an array containing all the values in array1 that are present in all other arguments. |
array_uintersect_uassoc()
[Computes the intersection of arrays with additional index check, compares data and indexes by separate callback functions] |
Computes the intersection of arrays with additional index check, comparing data and indexes by separate value_compare and key_compare functions. | array_uintersect_uassoc(array1, array2, array3 [optional parameter]…, value_compare, key_compare);
[The callback functions must return an integer less than, equal to, or greater than 0, depending on whether argument one is considered respectively to be less than, equal to, or greater than argument two.] |
array_uintersect_uassoc() : returns an array containing all the values of array1 that are present in all other arguments. |
array_uintersect()
[Computes the intersection of arrays, compares data by a callback function] |
Computes the intersection of arrays, comparing data via callback_function. | array_uintersect(array1, array2, array3 [optional parameter]…, callback_function);
[callback_function must return an integer less than, equal to, or greater than 0, depending on whether argument one is considered respectively to be less than, equal to, or greater than argument two.] |
array_uintersect() : returns an array containing all the values of array1 that are present in all other arguments. |
array_unique()
[Removes duplicate values from an array] |
Returns a new array, consisting of unique input values. Keys are preserved, and if multiple elements are considered equal according to the specified sort_flags then the key and value of the first element will be retained. | array_unique(input, sort_flags [optional parameter]);
[sort_flags types: SORT_REGULAR, SORT_NUMERIC, SORT_STRING [default], SORT_LOCALE_STRING.] |
Returns the unique, duplicate-less array. |
array_unshift()
[Prepend one or more elements to the beginning of an array] |
Prepends all passed elements as a whole to the front of array. Numerical keys are re-indexed to start counting from zero; literal keys are unmodified. | array_unshift(array, value... [one or more optional values to prepend]); |
Returns the new number of elements in the array, after the unshift-ing operation has been performed. |
array_values()
[Returns all the values from the array and indexes the array numerically] |
Returns all the values from array and indexes the array numerically. | array_values(array); |
Returns an indexed array of values. |
array_walk_recursive()
[Apply a user function recursively to every member of an array] |
Applies callback_function to each element of array. This function will recurse into deeper arrays. | array_walk_recursive(array, callback_function, userdata [optional parameter]);
[If specified, userdata will be passed as the third parameter (after value and key) to callback_function. Passing value as a reference (by prefixing ‘$value’ with an ampersand – ‘&$value’) allows the original value to be altered. Any key that holds an array will not be passed to the function.] |
array_walk_recursive() : returns TRUE on success or FALSE on failure. |
array_walk()
[Apply a user-supplied function to every member of an array] |
Applies the user-supplied callback_function to every member of array. The function will walk through the entire array regardless of the position of the internal pointer. Since PHP 7.1.0, an ArgumentCountError will be thrown if callback_function requires more than two parameters [the value and key of the array member]. Previously, an E-WARNING -level error would be emitted each time callback_function was called. |
array_walk(array, callback_function, userdata [optional parameter]);
[If specified, userdata will be passed as the third parameter (after value and key) to callback_function. Passing value as a reference (by prefixing ‘$value’ with an ampersand – ‘&$value’) allows the original value to be altered.] |
array_walk() : returns TRUE on success or FALSE on failure. |
arsort()
[Sort an array in reverse order and maintain index association] |
Sorts associative_array in reverse order, according to the value. Array indices maintain their correlation with the array elements they are associated with. If two members compare as equal, their relative order in the sorted array is undefined. | arsort(associative_array, sort_flags [optional parameter]);
[sort_flags can have the following values: SORT_REGULAR; SORT_NUMERIC; SORT_STRING; SORT_LOCALE_STRING; SORT_NATURAL; and SORT_FLAG_CASE.] |
arsort() : returns TRUE on success or FALSE on failure. |
asort()
[Sort an array and maintain index association] |
Sorts associative_array in ascending order, according to the value. Array indices maintain their correlation with the array elements they are associated with. If two members compare as equal, their relative order in the sorted array is undefined. | asort(associative_array, sort_flags [optional parameter]);
[sort_flags can have the following values: SORT_REGULAR; SORT_NUMERIC; SORT_STRING; SORT_LOCALE_STRING; SORT_NATURAL; and SORT_FLAG_CASE.] |
asort() : returns TRUE on success or FALSE on failure. |
compact()
[Create array containing variables and their values] |
Compact() does the opposite of extract() – in the output array, the variable name becomes the key and the variable contents becomes the value for that key. Any strings that are not set will simply be skipped. |
compact(variable_name1, variable_name2... [optional parameter]);
[ |
Returns the ‘compact-ed’ output array with all the variables added to it. |
count()
[Count all elements in an array, or something in an object] |
Counts all elements in an array, or something in an object. Regarding objects, if you have ‘SPL’ installed, you can hook into count() by implementing interface Countable . Alias of sizeof() . |
count(array_or_countable [an array or countable object], count_mode... [optional parameter]);
[count_mode can be set to COUNT_RECURSIVE (or 1), facilitating a recursive count of the array.] |
Counts and returns the number of elements in array_or_countable. When the parameter is neither an array nor an object implementing the Countable interface, 1 will be returned. If array_or_countable is NULL , 0 will be returned. |
current()
[Return the current element in an array] |
Every array has an internal pointer to its current element, which is initialized to the first element inserted into the array. This function does not move the internal pointer in any way. Alias of pos() . |
current(array);
[As of PHP 7.0.0 array is always passed by value; beforehand, it was passed by reference whenever possible.] |
Returns the value of the array element that is currently being pointed to by the internal pointer. If the internal pointer points beyond the end of the elements list or the array is empty, FALSE is returned. |
each()
[Return the current key and value pair from an array and advance the array cursor] |
Advances the array cursor after returning the current key and value pair from array. This function has been deprecated as of PHP 7.2.0. | each(array); |
Returns the current key and value pair from array. This pair is returned in a four-element array, with the keys 0, 1, key, and value. Elements 0 and key contain the key name of the array element, while 1 and value contain the data. FALSE is returned if the internal pointer points past the end of the array contents. |
end()
[Set the internal pointer of an array to its last element] |
Propels array‘s internal pointer to its last [‘end’] element and returns the value. | end(array);
[array is passed by reference.] |
Returns the value of array‘s last element, or FALSE for an empty array. |
extract()
[Import variables into the current symbol table from an array] |
Extracts variables from array and imports them into the current symbol table. Each key is checked to see whether it has a valid variable name. A check for collisions with existing variables in the symbol table also occurs. array must be an associative array, since this function treats keys as variable names and values as variable values; a numerically-indexed array will not produce results unless either the EXTR_PREFIX_ALL or the EXTR_PREFIX_INVALID flag is used. | extract(array, extract_flag [optional], extract_prefix [optional]);
[extract_flag comprises the following options: EXTR_OVERWRITE [default]; EXTR_SKIP; EXTR_PREFIX_SAME; EXTR_PREFIX_ALL; EXTR_PREFIX_INVALID; EXTR_IF_EXISTS; EXTR_PREFIX_IF_EXISTS; EXTR_REFS.] |
Returns the number of variables successfully extracted and imported into the symbol table. |
in_array()
[Checks if a value exists in an array] |
Searches in array for value, using loose comparison unless strict is set. If value is a string, the comparison is performed in a case-sensitive manner. | in_array(value, array, strict [optional]);
[If strict is set to TRUE then the types of search value and array values are also compared.] |
Returns TRUE if value is found in array; otherwise FALSE. |
key()
[Fetch a key from an array] |
Returns the index element of the current array position. This function does not move the internal pointer in any way. | key(array);
[As of PHP 7.0.0 array is always passed by value; beforehand, it was passed by reference whenever possible.] |
Returns the key of the array element that is currently being pointed to by the internal pointer. NULL is returned if the internal pointer points beyond the end of the elements list, or if array is empty. |
krsort()
[Sort an array by key in reverse order] |
Sorts array by key in reverse order, maintaining key-data correlations. | krsort(array, sort_flag [optional]);
[sort_flag options: SORT_REGULAR; SORT_NUMERIC; SORT_STRING; SORT_LOCALE_STRING; SORT_NATURAL; and SORT_FLAG_CASE.] |
krsort() : returns TRUE on success; FALSE on failure. |
ksort()
[Sort an array by key] |
Sorts array by key, maintaining key-data correlations. | ksort(array, sort_flag [optional]);
[sort_flag options: SORT_REGULAR; SORT_NUMERIC; SORT_STRING; SORT_LOCALE_STRING; SORT_NATURAL; and SORT_FLAG_CASE.] |
ksort() : returns TRUE on success; FALSE on failure. |
list()
[Assign variables as if they were an array] |
Assigns a list of variables in one operation. list() only works on numerical arrays and assumes the numerical indices start at 0. In PHP 5, list() assigns the values starting with the right-most parameter; in PHP 7 this assignment order has been inverted. Attention must be paid when using this function with arrays. |
list(variable1, variable2... [optional]); |
Returns the assigned array. |
natcasesort()
[Sort an array using a case-insensitive “natural order” algorithm] |
Implements a sort algorithm that orders alphanumeric strings in the way a human being would while maintaining key-value associations: a “natural ordering”. If two members compare as equal their relative order in the sorted array is undefined. This is a case-insensitive version of natsort() . |
natcasesort(array); |
natcasesort() : returns TRUE on success, FALSE on failure. |
natsort()
[Sort an array using a “natural order” algorithm] |
Implements a sort algorithm that orders alphanumeric strings in the way a human being would while maintaining key-value associations: a “natural ordering”. If two members compare as equal their relative order in the sorted array is undefined. This is a case-sensitive version of natcasesort() . |
natsort(array); |
natsort() : returns TRUE on success, FALSE on failure. |
next()
[Advance the internal pointer of an array] |
Advances the internal pointer of array by one [i.e. to the next element] and returns the value found there. | next(array); |
Returns the value pointed to after advancing the internal pointer to the next element, or FALSE if there are no more elements. |
prev()
[Rewind the internal array pointer] |
Rewinds the internal pointer of array by one [i.e. to the previous element] and returns the value found there. | prev(array); |
Returns the value pointed to after rewinding the internal pointer to the previous element, or FALSE if there are no more elements. |
range()
[Create an array containing a range of elements] |
Creates an array containing a range of elements. | range(start, end, step [optional]);
[If step is specified it will be used as the increment between elements in the sequence. Should be given as a positive number. Default is 1.] |
Returns an array of elements, ranging from start to end, inclusive. |
reset()
[Set the internal pointer of an array to its first element] |
Rewinds [‘resets’] array‘s internal pointer to the first element and returns the value found there. | reset(array); |
Returns the value of the first array element, or FALSE if the array is empty. |
rsort()
[Sort an array in reverse order] |
Sorts the values of array in descending [reverse] order. If two members compare as equal their relative order in the sorted array is undefined. Assigns new keys to the elements of array. | rsort(array, sort_flags [optional]);
[sort_flags options: SORT_REGULAR; SORT_NUMERIC; SORT_STRING; SORT_LOCALE_STRING; SORT_NATURAL; and SORT_FLAG_CASE.] |
rsort() : returns TRUE on success or FALSE on failure. |
shuffle()
[Shuffle an array] |
Shuffles an array [randomizes the array’s elemental ordering], using a pseudo random number generator unsuitable for cryptographic purposes. If two elements compare as equal their relative position in the shuffled array is undefined. New keys are assigned to the elements in array. |
shuffle(array); |
shuffle() : returns TRUE on success or FALSE on failure. |
sort()
[Sort an array] |
Sorts an array in ascending elemental order. If two elements compare as equal their relative order in the sorted array is undefined. New keys are assigned to elements in array. | sort(array, sort_flags [optional]);
[The following sort_flags are available: SORT_REGULAR; SORT_NUMERIC; SORT_STRING; SORT_LOCALE_STRING; SORT_NATURAL; and SORT_FLAG_CASE.] |
sort() : returns TRUE on success or FALSE on failure. |
uasort()
[Sort an array with a user-defined comparison function and maintain index association] |
Sorts array such that array indices maintain their correlation with the elements they are associated with, using a user-defined comparison_function. If two members compare as equal their relative order in the sorted array is undefined. | uasort(array, comparison_function);
[comparison_function must return an integer less than, equal to, or greater than 0 depending upon whether the first argument is considered to be respectively less than, equal to, or greater than the second argument.] |
uasort() : returns TRUE on success or FALSE on failure. |
uksort()
[Sort an array by keys using a user-defined comparison function] |
Sorts the keys of array, using a user-defined comparison_function. If two members compare as equal their relative order in the sorted array is undefined. | uksort(array, comparison_function);
[comparison_function must return an integer less than, equal to, or greater than 0 depending upon whether the first argument is considered to be respectively less than, equal to, or greater than the second argument.] |
uksort() : returns TRUE on success or FALSE on failure. |
usort()
[Sort an array by values using a user-defined comparison function] |
Sorts the values of array, using a user-defined comparison_function. If two members compare as equal their relative order in the sorted array is undefined. New keys are assigned to elements in array. | usort(array, comparison_function);
[comparison_function must return an integer less than, equal to, or greater than 0 depending upon whether the first argument is considered to be respectively less than, equal to, or greater than the second argument.] |
usort() : returns TRUE on success or FALSE on failure. |
Forty-year-old father of three wonderful children [William, Seth, and Alyssa]. Works as an Assistant Technical Officer in the Sterile Services Department of Treliske Hospital, Cornwall. Enjoys jogging, web design, learning programming languages, and supporting Arsenal FC. Obtained a BA degree in English from the University of Bolton in 2008, and has continued to gain qualifications in a diverse range of subjects thereafter.
Leave a Reply