somejkuser
somejkuser

Reputation: 9040

getting an array of key values from a mulitidimensional array

$array = array(
   array(
      'display' => 'hi',
      'title' => 'hi'
   ),
   array(
      'display' => 'hi2',
      'title' => 'hi2'
   )
);

What I need is an array containing all of the display values.

Upvotes: 0

Views: 31

Answers (1)

Rizier123
Rizier123

Reputation: 59701

This is perfect for array_column(). You can use it like this:

$values = array_column($array, "display");
print_r($values);

Output:

Array ( [0] => hi [1] => hi2 )

For more information about array_column() see the manual: http://php.net/manual/en/function.array-column.php

Upvotes: 3

Related Questions