Home » » array_search

array_search

Written By 1 on Sunday, September 30, 2012 | 7:08 PM

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(=> 'blue'=> 'red'=> 'green'=> '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