3v4l.org

run code in 300+ PHP versions simultaneously
<?php $report = array ( '18427e904f7a227e8c3b80dd2858a70e' => array ( 'needle' => array ( 0 => array ( 'starts_at' => 11821, 'ends_at' => 14377, 'length' => 2556, 'original' => 'foo' ), ), 'haystack' => array ( 0 => array ( 'starts_at' => 12227, 'ends_at' => 14783, 'length' => 2556, 'original' => 'foo' ), ), ), 'dd0c26f35ebf55de25eabea3edbfba32' => array ( 'needle' => array ( 0 => array ( 'starts_at' => 17255, 'ends_at' => 32431, 'length' => 15176, 'original' => 'foo' ), ), 'haystack' => array ( 0 => array ( 'starts_at' => 17776, 'ends_at' => 33032, 'length' => 15256, 'original' => 'foo' ), ), )); var_dump(remapMatches($report, true)); function remapMatches($matches) { $remapped = []; foreach ($matches as $fingerprint => $match) { $remapped[$fingerprint] = $match; $needle = $remapped[$fingerprint]['needle']; $haystack = $remapped[$fingerprint]['haystack']; unset($needle); unset($haystack); foreach ($remapped[$fingerprint]['needle'] as &$needle_2) unset($needle_2['original']); foreach ($remapped[$fingerprint]['haystack'] as &$haystack_2) unset($needle_2['original']); } return $remapped; }
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
array(2) { ["18427e904f7a227e8c3b80dd2858a70e"]=> array(2) { ["needle"]=> array(1) { [0]=> array(3) { ["starts_at"]=> int(11821) ["ends_at"]=> int(14377) ["length"]=> int(2556) } } ["haystack"]=> array(1) { [0]=> array(4) { ["starts_at"]=> int(12227) ["ends_at"]=> int(14783) ["length"]=> int(2556) ["original"]=> string(3) "foo" } } } ["dd0c26f35ebf55de25eabea3edbfba32"]=> array(2) { ["needle"]=> array(1) { [0]=> array(3) { ["starts_at"]=> int(17255) ["ends_at"]=> int(32431) ["length"]=> int(15176) } } ["haystack"]=> array(1) { [0]=> array(4) { ["starts_at"]=> int(17776) ["ends_at"]=> int(33032) ["length"]=> int(15256) ["original"]=> string(3) "foo" } } } }

preferences:
153.24 ms | 411 KiB | 5 Q