3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = array( 'foo', 'bar', 'baz', ); $filtered_array = array_filter( $array, fn ( $value ) => $value !== 'bar', ); var_dump( $filtered_array ); echo "New: "; echo array_last( $filtered_array ); echo "Old: "; echo $filtered_array[ count( $filtered_array ) - 1 ];
Output for 8.5.7 - 8.5.9
array(2) { [0]=> string(3) "foo" [2]=> string(3) "baz" } New: bazOld: Warning: Undefined array key 1 in /in/cMG4N on line 20
Output for 8.2.32, 8.3.5 - 8.3.32, 8.4.9 - 8.4.23
array(2) { [0]=> string(3) "foo" [2]=> string(3) "baz" } New: Fatal error: Uncaught Error: Call to undefined function array_last() in /in/cMG4N:17 Stack trace: #0 {main} thrown in /in/cMG4N on line 17
Process exited with code 255.

preferences:
43.67 ms | 528 KiB | 4 Q