How to convert multi-dimensional array into one-dimensional array in thinkphp?
天蓬老师
天蓬老师 2017-05-16 13:13:51
0
3
382

Array
(

[0] => Array
    (
        [user_id] => 1
    )

[1] => Array
    (
        [user_id] => 22
    )

)
I only want 1 and 22. How to change it into $a=array('1','22');

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(3)
滿天的星座
php版本要大于5.5.0
$userid_array = array_column($x,'userid');


php版本要大于5.4.0
$userid_array = array_map(function($item){return $item['userid'];},$x);

再低就for循环吧
淡淡烟草味

array_map("current", two-dimensional array);

伊谢尔伦

Do you need to query by column? Such a query can directly find the data of a one-digit array

$use_id = Db->table('table')->where([])->column('user_id');
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template