array_column($arr,'valColumn','keyColumn');

 

此方法是用户二维数组,如下例子:

  
$arr=array(

array('id'=>1,'name'=>'MYSQL','sub_name'=>'mysql'),
array('id'=>2,'name'=>'Oracle','sub_name'=>'oracle'),
array('id'=>3,'name'=>'Redis','sub_name'=>'redis'),

);


var_dump(array_column($arr,'name','sub_name'));
运行结果:

如果需要一列值:
array_column($arr,'name');
运行结果: