Haifa linux club:PHP lecture
Prev Next


array functions


(partial list)
count - Count elements in a variable
array_pop - Pop the element off the end of array
array_push - Push one or more elements onto the end of array
array_reverse - Return an array with elements in reverse order
array_shift - Shift an element off the beginning of array
array_unshift - Prepend one or more elements to the beginning of array
array_sum - Calculate the sum of values in an array.
array_unique - Removes duplicate values from an array
array_values - Return all the values of an array
in_array - Return TRUE if a value exists in an array
array_search - Searches the array for a given value and returns the corresponding key if successful
sizeof - Get the number of elements in variable
sort - Sort an array
uksort - Sort an array by keys using a user-defined comparison function
usort - Sort an array by values using a user-defined comparison function
<?
function cmp ($a$b) {   
    if (
$a == $b) return 0;
    return (
$a $b) ? -1;
}

$a = array (32561);

usort ($a"cmp");
?>

array_flip - Flip all the values of an array
<?
$trans 
= array ("a" => 1"b" => 1"c" => 2);
$trans array_flip ($trans);
// now $trans is : array(1 => "b", 2 => "c");
?>



HOME