PHP - Extracting a property from an array of objects

前端 未结 10 1002
时光取名叫无心
时光取名叫无心 2020-12-02 05:16

I\'ve got an array of cats objects:

$cats = Array
    (
        [0] => stdClass Object
            (
                [id] => 15
            ),
                 


        
10条回答
  •  囚心锁ツ
    2020-12-02 05:25

    // $array that contain records and id is what we want to fetch a
    $ids = array_column($array, 'id');
    

提交回复
热议问题