3v4l.org

run code in 300+ PHP versions simultaneously
<?php $haystack = [7, 6, 14, 15, 8, 0, 1, 4, 5, 9]; $needles = [ [3, 2, 7, 6], [7, 6, 15, 14], [15,14,11,10], [1,3,5,7], [5,7,13,15], [13,15,9,11], [0,1,4,5], [4,5,12,13], ]; // assuming all needle values are unique and all values in each haystacks subarray are unique function getIndexOfMatchingArrays(array $needles, array $haystack) { if (!$haystack) { return -1; } foreach ($needles as $index => $needle) { if ($needle === array_intersect($needle, $haystack)) { $fullMatch[] = $index; } } return $fullMatch ?? -1; } var_export( getIndexOfMatchingArrays($needles, $haystack) );
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => 1, 1 => 6, )

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:
33.61 ms | 405 KiB | 9 Q