是否有任何PHP array_ *函数用于从多维数组中提取单个值? [重复]

This question already has an answer here:

If I have a multidimensional array, and I want to extract some of the data from it and place them in a new array, is there any existing array_*() function to do so?

For example, if I have the following array:

array(
    [
        'id'    => 1,
        'num'   => 200,
        'text'  => 'abc'
    ],
    [
        'id'    => 2,
        'num'   => 230,
        'text'  => 'def'
    ],
    [
        'id'    => 3,
        'num'   => 100,
        'text'  => 'ghi'
    ],

)

I would like to get the following resulting array:

[ 'abc', 'def', 'ghi' ]

Of course I can always do it manually using foreach() or something similar, but one-liners are always nice :)

</div>

Try array_column function;

array_column(array $data, 'key')

You may use array_map() in php

<?php
    $array = array([
            'id'    => 1,
            'num'   => 200,
            'text'  => 'abc'
        ],
        [
            'id'    => 2,
            'num'   => 230,
            'text'  => 'def'
        ],
        [
            'id'    => 3,
            'num'   => 100,
            'text'  => 'ghi'
        ],

    );


    $return = array_map(function ($value) {
        return  $value['text'];
    }, $array);

    echo "<pre>"; 
    print_R($return);
    ?>