3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = ['First', 'Second', 'Third', 'Fourth', 'Fifth', 'Sixth']; $temp = $data; $result = []; foreach($data as $i=>$item) { $item = array_shift($temp); $pair = array_rand($temp); $result[] = [$item, $temp[$pair]]; unset($temp[$pair]); } var_dump($result);

preferences:
65.47 ms | 402 KiB | 5 Q