3v4l.org

run code in 300+ PHP versions simultaneously
<?php $firstArray = array('22','24','23','26','22','24','23','26'); $secondArray = array('John','Smith','Mark','Steve','George','Nick','Sean','Brad'); $thirdArray = array('A','B','D','E','F','G','H','I'); $new1 = []; $new2 = []; $new3 = []; foreach (array_flip($firstArray) as $index) { $new1[] = $firstArray[$index]; $new2[] = $secondArray[$index]; $new3[] = $thirdArray[$index]; } var_dump($new1, $new2, $new3);

preferences:
24.5 ms | 405 KiB | 5 Q