3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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);
based on NlITb
Output for 7.1.0 - 7.2.0
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 - 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 ( )
Output for 5.3.21 - 5.4.45
Fatal error: Call to undefined function array_column() in /in/h4iGj on line 33
Process exited with code 255.