php基本函数汇总(3)

$user = array( 0 => array( 'id' => 1, 'name' => '张三', 'email' => 'zhangsan@sina.com', ), 1 => array( 'id' => 2, 'name' => '李四', 'email' => 'lisi@163.com', ), 2 => array( 'id' => 5, 'name' => '王五', 'email' => '10000@qq.com', ), ...... ); $ids = array(); $ids = array_map('array_shift', $user); $ids = array_column($user, 'id');//php5.5 $names = array(); $names = array_reduce($user, create_function('$v,$w', '$v[$w["id"]]=$w["name"];return $v;'));

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/b4f1196498c40fbcbb0a44836fe91295.html