3v4l.org

run code in 300+ PHP versions simultaneously
<?php $users=Array ( 0 => Array ( 'id' => 111, 'name' => 'Sandra Shush', 'sources' => '1234,678,780,199' ), 1 => Array ( 'id' => 112, 'name' => 'Stefanie Mcmohn', 'sources' => '32,99,85' ), 2 => Array ( 'id' => 113, 'name' => 'Michael', 'sources' => '896,1213,1918' ), 3 => Array ( 'id' => 113, 'name' => 'Michael', 'sources' => '72' ) ); print_r(array_map('str_getcsv',array_column($users,'sources'))); $result = array_filter(array_map('str_getcsv',array_column($users,'sources')),function($k,$v){ if(in_array(99,$v)) return $k;}); print_r($result);
Output for 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Array ( [0] => Array ( [0] => 1234 [1] => 678 [2] => 780 [3] => 199 ) [1] => Array ( [0] => 32 [1] => 99 [2] => 85 ) [2] => Array ( [0] => 896 [1] => 1213 [2] => 1918 ) [3] => Array ( [0] => 72 ) ) Fatal error: Uncaught ArgumentCountError: Too few arguments to function {closure}(), 1 passed and exactly 2 expected in /in/h4iGj:34 Stack trace: #0 [internal function]: {closure}(Array) #1 /in/h4iGj(34): array_filter(Array, Object(Closure)) #2 {main} thrown in /in/h4iGj on line 34
Process exited with code 255.
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20
Array ( [0] => Array ( [0] => 1234 [1] => 678 [2] => 780 [3] => 199 ) [1] => Array ( [0] => 32 [1] => 99 [2] => 85 ) [2] => Array ( [0] => 896 [1] => 1213 [2] => 1918 ) [3] => Array ( [0] => 72 ) ) Warning: Missing argument 2 for {closure}() in /in/h4iGj on line 34 Notice: Undefined variable: v in /in/h4iGj on line 34 Warning: in_array() expects parameter 2 to be array, null given in /in/h4iGj on line 34 Warning: Missing argument 2 for {closure}() in /in/h4iGj on line 34 Notice: Undefined variable: v in /in/h4iGj on line 34 Warning: in_array() expects parameter 2 to be array, null given in /in/h4iGj on line 34 Warning: Missing argument 2 for {closure}() in /in/h4iGj on line 34 Notice: Undefined variable: v in /in/h4iGj on line 34 Warning: in_array() expects parameter 2 to be array, null given in /in/h4iGj on line 34 Warning: Missing argument 2 for {closure}() in /in/h4iGj on line 34 Notice: Undefined variable: v in /in/h4iGj on line 34 Warning: in_array() expects parameter 2 to be array, null given in /in/h4iGj on line 34 Array ( )

preferences:
170.7 ms | 405 KiB | 183 Q