3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function sales_search($arr, $needle) { foreach ($arr as $id => $data) { if (in_array($needle, $data['states'])) { return $id; } if (in_array($needle, $data['codes'])) { return $id; } } return false; } $sales_people = array( '2' => array( 'states' => array('NY', 'NJ', 'CT', 'MA', 'VT', 'ME'), 'codes' => array('CA1', 'US7', 'UT9') ), '5' => array( 'states' => array('FL', 'GA', 'SC', 'NC', 'TN'), 'codes' => array('VA4', 'VA8', 'VA3') ) ); var_dump(sales_search($sales_people, 'VA4'));
Output for 4.3.0 - 7.1.0
int(5)