3v4l.org

run code in 300+ PHP versions simultaneously
<?php $balls = [['001', '001', '003', '004', '005'], ['012', '004', '007', '010', '005'], ['011', '007', '009', '008', '005']]; $searchMatches = function($balls) { foreach ($balls as $rowNumber => $rowData) { $repeating = array_filter(array_count_values($rowData), function ($count) { return $count > 1; }); if ($repeating) { $tmpRow = $rowData; foreach ($repeating as $value => $count) { for ($i = 1; $i <= $count; $i++) { $index = array_search($value, $tmpRow); $matchesRow[$rowNumber][$index] = $value; unset($tmpRow[$index]); } } } } return $matchesRow; }; $reverseBalls = []; foreach($balls as $rowNumber => $rowData) { $count = count($rowData); for($i = 0; $i < $count; $i++) { $reverseBalls[$i][$rowNumber] = $rowData[$i]; } } var_dump($searchMatches($balls)); var_dump($searchMatches($reverseBalls));
Output for git.master, git.master_jit, rfc.property-hooks
array(1) { [0]=> array(2) { [0]=> string(3) "001" [1]=> string(3) "001" } } array(1) { [4]=> array(3) { [0]=> string(3) "005" [1]=> string(3) "005" [2]=> string(3) "005" } }

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:
60.68 ms | 401 KiB | 8 Q