Searches the array for a given value and returns the key

by sabitha 2012-06-05 14:22:11

Searches the array for a given value and returns the key



array_search - This function searches the array for a given value and returns the key if found

$myarr = array(0=>"apple", 1=>"orange", 2=>"banana", 3=>"orange");
$res = array_search('orange', $myarr);
print_r($res);

will outputs
1

Tagged in:

420
like
0
dislike
0
mail
flag

You must LOGIN to add comments