array_search

Syntax: mixed array_search ( mixed $needle , array $haystack [, bool $strict = false ] )
Description: Searches the array for a given value and returns the corresponding key if successful

<?php
$array = array(0 => 'blue', 1 => 'red', 2 => 'green', 3 => 'red');

$key = array_search('green', $array);
echo $key."<br/>"; 
$key = array_search('red', $array);
echo $key."<br/>";  
?>
   

OUTPUT

2
1