3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = ["1", "2", "3", "4", "5"]; $removed = array_splice( $array, -(count($array) >> 1) ); var_export([ 'first half' => $array, 'second half' => $removed ]);
Output for 8.1.32, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
array ( 'first half' => array ( 0 => '1', 1 => '2', 2 => '3', ), 'second half' => array ( 0 => '4', 1 => '5', ), )

preferences:
58.44 ms | 406 KiB | 5 Q