Function |
Description |
| array_change_key_case() | Change all key case |
| array_chunk() | Returns a multidimensional array of the chunked array |
| array_combine() | Combine two arrays, one array becomes the keys and the other the values |
| array_count_values() | Count values in an array |
| array_diff() | Evaluate the difference in arrays |
| array_fill_keys() | Specify keys of an array as it gets values put into it |
| array_fill() | Fill an array with values specifying starting index and fill value |
| array_filter() | Filters elements |
| array_flip() | Swap all keys with their values |
| array_intersect() | Evaluate the intersection of arrays |
| array_key_exists() | Checks if the given key or index exists |
| array_keys() | List all keys |
| array_merge_recursive() | Recursively merge elements from two or more arrays |
| array_merge() | Merge the elements from one or more arrays |
| array_multisort() | Sort multiple arrays |
| array_pad() | Pad an array to match a given length |
| array_pop() | Pop the last element off the end |
| array_product() | Get the product of values |
| array_push() | Add to the end of an array |
| array_rand() | Get random items from an array |
| array_reduce() | Reduce the array to a single value |
| array_replace_recursive() | Replace array data recursively |
| array_replace() | Replace array data |
| array_reverse() | Reverse an array |
| array_search() | Returns the key of values searched for and found in an array |
| array_shift() | Remove the first element in an array and return the value |
| array_slice() | Remove a specified element of an array |
| array_splice() | Replace a specified element of an array |
| array_sum() | Evaluate the sum of values in an array |
| array_unique() | Removes duplicate values from an array |
| array_unshift() | Add elements to the beginning of an array |
| array_values() | Return all the values of an array |
| array_walk_recursive() | Run a function recursively on every item of an array |
| array_walk() | Run a function on every item of an array |
| arsort() | Sort an array in reverse and maintain index association |
| asort() | Sort an array and maintain index association |
| compact() | Uses variable names as keys and their values as array values |
| count() | Count elements in an array |
| current() | Return the current element |
| each() | Return the current key value pair |
| end() | Move the internal pointer to the last element in an array |
| extract() | Create PHP variables with values from an array |
| in_array() | Checks if a value exists in an array |
| key() | Get a key from an array |
| krsort() | Sort an array by key in reverse order |
| ksort() | Sort an array by key |
| list() | Create a list of variables from an array |
| natcasesort() | Sort an array using a case insensitive natural order algorithm |
| natsort() | Sort an array using a natural order algorithm |
| next() | Move the internal pointer of an array ahead |
| pos() | See current() |
| prev() | Move the internal pointer of an array backward |
| range() | Returns an array made up of a range of elements from an original array |
| reset() | Move the internal pointer of an array to the first element |
| rsort() | Sort an array in reverse order |
| shuffle() | Randomly shuffle an array |
| sizeof() | See count() |
| sort() | Sort an array |
| uasort() | Sort an array with a user defined comparison |
| uksort() | Sort an array by keys with a user defined comparison |
| usort() | Sort an array by values with a user defined comparison |
Friday, January 4, 2013
PHP Array Functions
array_pop()
array_pop — Pop the element off the end of array
array_pop() pops and returns the last value of the
array_pop() pops and returns the last value of the
array, shortening the array by one element. If array is empty (or is not an array), NULL will be returned. Will additionally produce a Warning when called on a non-array.
<?php
$stack = array("orange", "banana", "apple", "raspberry");
$fruit = array_pop($stack);
print_r($stack);
?>
Array
(
[0] => orange
[1] => banana
[2] => apple
)
Subscribe to:
Comments (Atom)