duanchao4445
2017-05-11 08:40 阅读 28
已采纳

从多维数组中获取用户ID数组[重复]

This question already has an answer here:

I've the following array:

Array
(
[0] => Array
    (
        [ID] => 1
        [more_user_data] => More
    )

[1] => Array
    (
        [ID] => 2
        [more_user_data] => More 
    )

)

Now I want to have a comma separated list of the IDs to use them in an own array. To get something like this:

array(1,2)

How could I only extract the IDs from the second array?

</div>
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    dougaopu7938 dougaopu7938 2017-05-11 08:42

    Use array_column() function like:

    $arr = array_column($array, 'ID');
    

    Working Example

    点赞 评论 复制链接分享

相关推荐