mixed array_search ( mixed $needle , array $haystack [, bool $strict = false ] )
Searches the array for a given value and returns the corresponding key if successful
Searches haystack for needle.
<?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;
?>
5.3.0 As with all internal PHP functions as of 5.3.0, array_search() returns NULL if invalid parameters are passed to it. 4.2.0 Prior to PHP 4.2.0, array_search() returns NULL on failure instead of FALSE.
Tutoriel pour apprendre php-mysql (array_search)
0 Comment:
Post a Comment