- in_array — Checks if a
value exists in an array return True or False
- array_search: Searches the array for a
given value and returns the corresponding key if successful
- array_combine : Creates an array by using one array for
keys and another for its values
- The array_slice() function returns selected parts of an array.
- array_merge — Merge one or more arrays
- array_sum — Calculate the sum of values in an array
- list — Assign variables as if they were an array
- call_user_func — Call the callback given by the first paramet
- call_user_func_array — Call a callback with an array of parameters
- array_intersect_key
in_array — Checks if a
value exists in an array
return True or False
no example
array_search: Searches the array for a
given value and
returns the corresponding
key if successful
Example:
[php]<!--?php $array = array(0 =--> 'blue', 1 => 'red', 2 => 'green', 3 => 'red');
$key = array_search('green', $array); // $key = 2;
$key = array_search('red', $array); // $key = 1;
?>
[/php]
array_combine : Creates an
array by using one array for
keys and another for its
values
Example:
[php]
<!--?php $a = array('green', 'red', 'yellow'); $b = array('avocado', 'apple', 'banana'); $c = array_combine($a, $b); print_r($c); ?-->
[/php]
The
array_slice() function returns selected parts of an array.
[php]</pre>
<!--?php $input = array("a", "b", "c", "d", "e"); $output = array_slice($input, 2); // returns "c", "d", and "e" $output = array_slice($input, -2, 1); // returns "d" $output = array_slice($input, 0, 3); // returns "a", "b", and "c" // note the differences in the array keys print_r(array_slice($input, 2, -1)); print_r(array_slice($input, 2, -1, true)); ?-->
<pre>[/php]
Output:
Array
(
[0] => c
[1] => d
)
Array
(
[2] => c
[3] => d
)
list — Assign variables as if they were an array
[php]<!--?php list($a, list($b, $c)) = array(1, array(2, 3)); var_dump($a, $b, $c); ?-->
[/php]
end — Set the internal pointer of an array to its last element
[php]
<!--?php $fruits = array('apple', 'banana', 'cranberry'); echo end($fruits); // cranberry ?-->
[/php]