0

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?

Cray
  • 5,307
  • 11
  • 70
  • 166

1 Answers1

4

Use array_column() function like:

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

Working Example

Mayank Pandeyz
  • 25,704
  • 4
  • 40
  • 59