Is there a function to extract a 'column' from an array in PHP?

前端 未结 14 1431
鱼传尺愫
鱼传尺愫 2020-11-21 07:33

I have an array of arrays, with the following structure :

array(array(\'page\' => \'page1\', \'name\' => \'pagename1\')
      array(\'page\' => \'pa         


        
14条回答
  •  时光取名叫无心
    2020-11-21 08:04

    Yes, there is a php built-in function called array_column which does what you are looking for.

    You would call it something like $name_keys = array_column($array, 'name'); to get the result that you are looking for.

    Please refer to the following entry in the PHP manual for more details:

    http://php.net/manual/en/function.array-column.php

提交回复
热议问题