3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* Function to reverse $arr from start to end*/ function reverseArray(&$arr, $start=0): void { $end = count($arr)-1; while ($start < $end) { [$arr[$start],$arr[$end]] = [$arr[$end],$arr[$start]]; $start++; $end--; } } $a = [1,2,3,4]; reverseArray($a); print_r($a);

preferences:
16.48 ms | 402 KiB | 5 Q