3v4l.org

run code in 300+ PHP versions simultaneously
<?php $names = ['Adamino', 'Pete', 'Mark', 'Gonz']; $pairs = []; $pair = $names[array_rand($names, 2)]; unset($names[$pair[0]], $names[$pair[1]]); $pairs[] = $pair; var_dump($pair); var_dump($pairs); var_dump($names); $result = "The PP randomizer has selected: \n"; foreach ($pairs as $p) { $result .= " -> {$p[0]} and {$p[1]}\n"; }
Output for 7.4.0 - 7.4.1
Warning: Illegal offset type in /in/Yc8Mp on line 7 Notice: Trying to access array offset on value of type null in /in/Yc8Mp on line 8 Notice: Trying to access array offset on value of type null in /in/Yc8Mp on line 8 NULL array(1) { [0]=> NULL } array(4) { [0]=> string(7) "Adamino" [1]=> string(4) "Pete" [2]=> string(4) "Mark" [3]=> string(4) "Gonz" } Notice: Trying to access array offset on value of type null in /in/Yc8Mp on line 18 Notice: Trying to access array offset on value of type null in /in/Yc8Mp on line 18
Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.26, 7.3.0 - 7.3.13
Warning: Illegal offset type in /in/Yc8Mp on line 7 NULL array(1) { [0]=> NULL } array(4) { [0]=> string(7) "Adamino" [1]=> string(4) "Pete" [2]=> string(4) "Mark" [3]=> string(4) "Gonz" }

preferences:
128.63 ms | 403 KiB | 157 Q