PHP Search an element in an array and return the key – PHP May 11, 2011 Pramod T P Leave a comment <?php $testArray = array(0 => 'value1', 1 => 'value4', 2 => 'value2', 3 => 'value3'); $key = array_search('value2', $testArray); // $key = 2; echo "Key is ".$key ; // 2 ?>