3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = array( array(1,2,3), array(4,5,3), array(7,8,4), array(9,10,4), array(11,12,4) ); $out1 = $out2 = []; $splitIndex = 2; foreach($input as $k => $v){ if($k < $splitIndex){ $out1[] = $v; }else{ $out2[] = $v; } } print_r($out1); print_r($out2);

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
163.75 ms | 2193 KiB | 11 Q