3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input= [ 'football GAME', 'cricket GAME', 'computer DEVICE', 'mobile DEVICE' ]; $needle = 'DEVICE'; $output = array_filter($input, fn($haystack) => str_contains($haystack, $needle)); var_export( [ 'filtered' => $output, 'found' => $output ? 'yes' : 'no' ] );
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
array ( 'filtered' => array ( 2 => 'computer DEVICE', 3 => 'mobile DEVICE', ), 'found' => 'yes', )
Output for 7.4.0 - 7.4.33
Fatal error: Uncaught Error: Call to undefined function str_contains() in /in/tFhUm:11 Stack trace: #0 [internal function]: {closure}('football GAME') #1 /in/tFhUm(11): array_filter(Array, Object(Closure)) #2 {main} thrown in /in/tFhUm on line 11
Process exited with code 255.

preferences:
88.87 ms | 402 KiB | 123 Q