3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $array = array( array( 'Field1' => 'red', 'Field2' => 'green', 'Field3' => 'blue' ), array( 'Field1' => 'pink', 'Field2' => 'pinkish', 'Field3' => 'barbiecolor' ), array( 'Field1' => 'red', 'Field2' => 'blue', ' Field3' => 'orange' ) ); $searchBy = array( 'Field1' => 'red', 'Field2' => 'blue' ); // use($searchBy) function find($a) { global $searchBy ; return array_intersect_assoc($searchBy, $a) == $searchBy; } $find = array_filter($array, "find"); print_r($find); ?>
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Array ( [2] => Array ( [Field1] => red [Field2] => blue [ Field3] => orange ) )