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.13, 8.6.0
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.2.36, 8.3.0 - 8.3.37, 8.4.1 - 8.4.27
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:
25.09 ms | 1167 KiB | 6 Q