3v4l.org

run code in 300+ PHP versions simultaneously
<?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($needle, $haystack) { $r = array(); foreach ( $haystack as $k => $a ) { array_intersect_assoc($needle, $a) == $needle and $r[$k] = $a; } return $r; } $find = find($searchBy, $array); print_r($find); ?>
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [2] => Array ( [Field1] => red [Field2] => blue [ Field3] => orange ) )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
50.98 ms | 401 KiB | 8 Q