1
2<?php
3$array = array(0 => 'blue', 1 => 'red', 2 => 'green', 3 => 'red');
4
5$key = array_search('green', $array); // $key = 2;
6$key = array_search('red', $array); // $key = 1;
7?>
8
9
1$people = array(
2 2 => array(
3 'name' => 'John',
4 'fav_color' => 'green'
5 ),
6 5=> array(
7 'name' => 'Samuel',
8 'fav_color' => 'blue'
9 ));
10$found_key = array_search('blue', array_column($people, 'fav_color'));