3v4l.org

run code in 500+ PHP versions simultaneously
<?php class X { public int $i; } $array = [new x, new x, new x]; $array[0]->i = 0; $array[1]->i = 1; $array[2]->i = 2; function foo(array $array) { $array[] = new x; $array[2]->i = 12; $array[3]->i = 3; print count($array)." elements in foo\n"; } print count($array)." elements before foo\n"; foo($array); print count($array)." elements after foo\n"; print_r($array[2]);

preferences:
79.76 ms | 2758 KiB | 5 Q