-1

I have an array that looks like this:

[meta_data] => Array
   [0] => Array
      (
         [id] => 100
         [name] => John
      )
   [1] => Array
      (
         [id] => 200
         [name] => Peter
      )
   [2] => Array
      (
         [id] => 300
         [name] => Peter
      )

What would be the simplest way to select all names from $meta_data?

Thanks.

2
  • 2
    That would be array-column. Commented Dec 3, 2020 at 14:23
  • Exactly what I was looking for, thank you! Commented Dec 3, 2020 at 14:26

1 Answer 1

0

see https://www.php.net/manual/en/function.array-column.php

var_dump(array_column($array['meta_data'], 'name'));
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.