3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ ['text' => 'I like Apples', 'id' => '102923'], ['text' => 'I like Apples and Bread', 'id' =>'283923'], ['text' => 'I like Apples, Bread, and Cheese', 'id' => '3384823'], ['text' => 'I like Green Eggs and Ham', 'id' =>'4473873'] ]; $search = 'Bread'; var_export( array_filter($array, fn($subarray) => str_contains($subarray['text'], $search)) );
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
array ( 1 => array ( 'text' => 'I like Apples and Bread', 'id' => '283923', ), 2 => array ( 'text' => 'I like Apples, Bread, and Cheese', 'id' => '3384823', ), )
Output for 7.4.0 - 7.4.33
Fatal error: Uncaught Error: Call to undefined function str_contains() in /in/ntMfF:12 Stack trace: #0 [internal function]: {closure}(Array) #1 /in/ntMfF(12): array_filter(Array, Object(Closure)) #2 {main} thrown in /in/ntMfF on line 12
Process exited with code 255.
Output for 7.3.0 - 7.3.33
Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW), expecting ')' in /in/ntMfF on line 12
Process exited with code 255.
Output for 7.2.0 - 7.2.34
Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW), expecting ',' or ')' in /in/ntMfF on line 12
Process exited with code 255.

preferences:
138.62 ms | 410 KiB | 5 Q