3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function array_pluck($key, $input) { if (is_array($key) || !is_array($input)) return array(); $array = array(); foreach($input as $v) { if(array_key_exists($key, $v)) $array[]=$v[$key]; } return $array; } $testArray = array('test' => array('a' => array('percy', 'mitch'), 'b', 'c')); $res = array_pluck('a', $testArray); print_r($res);
Output for 4.3.0 - 7.1.0
Array ( [0] => Array ( [0] => percy [1] => mitch ) )