从记录集中获取特定列

时间:2017-09-27 13:14:58

标签: php arrays

我想只获得20,19,17,16,21,32,33

Array
(
    [0] => Array
        (
            [product_id] => 20
        )

    [1] => Array
        (
            [product_id] => 19
        )

    [2] => Array
        (
            [product_id] => 17
        )

    [3] => Array
        (
            [product_id] => 16
        )

    [4] => Array
        (
            [product_id] => 21
        )

    [5] => Array
        (
            [product_id] => 32
        )

    [6] => Array
        (
            [product_id] => 33
        )

)

我只需要20,19,17,16,21,32,33值。

请帮忙

1 个答案:

答案 0 :(得分:1)

使用$product_id = array_column($array, 'product_id ');

检查documentation