$array(类似于这个数组)
Array ( [0] => Array ( [id] => 3 [name]=>'aaa') [1] => Array ( [id] => 4 [name]=>'bbb') [2] => Array ( [id] => 13 [name]=>'ccc') );
方法1
$ids = array();
$ids = array_map('array_shift', $array);
方法2(php>=5.5)
$ids = array();
$ids = array_column($array, 'id');
方法3
$names = array();
$names = array_reduce($array, create_function('$v,$w', '$v[$w["id"]]=$w["name"];return $v;'));
已有 0 条评论