3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $arr = array( 'arr1' => array( 'uids' => array('uid1','uid2','uid3','uid4'), 'dids' => array('did1','did2','did3','did4') ), 'arr2' => array( 'uids' => array('uid21','uid22','uid23','uid24'), 'dids' => array('did21','did22','did23','did24') ) ); $flatUids = array(); $flatDids = array(); $objTmp = (object) array('aFlat' => array()); array_walk_recursive($arr,function(&$v, $k, &$t){ if($k == 'uids') $t[] = $v; },$flatUids); var_dump($flatUids);
based on kPtph
Output for 5.3.0 - 5.3.2, 5.3.11 - 5.3.29, 5.4.1 - 7.2.0
array(0) { }
Output for 5.3.3 - 5.3.10, 5.4.0
Warning: Cannot use a scalar value as an array in /in/Nq8lb on line 20 Warning: Cannot use a scalar value as an array in /in/Nq8lb on line 20 Warning: Cannot use a scalar value as an array in /in/Nq8lb on line 20 array(0) { }
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/Nq8lb on line 18
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION in /in/Nq8lb on line 18
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/Nq8lb on line 18
Process exited with code 255.