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) unset($needle['original']); foreach ($remapped[$fingerprint]['haystack'] as &$haystack) unset($haystack['original']); } return $remapped; }

preferences:
47 ms | 402 KiB | 5 Q