首頁  >  問答  >  主體

如何只選擇數組中的一列

<p>我在laravel中有一個類似下面這樣的數組,我想提取其中的列。 </p> <pre class="brush:php;toolbar:false;">Array ( [0] => Array ( [table] => form_identification [column] => region ) [1] => Array ( [table] => form_identification [column] => province ) )</pre> <p>我希望輸出結果如下</p> <pre class="brush:php;toolbar:false;">Array ( [0] => Array ( [column] => region ) [1] => Array ( [column] => province ) )</pre></p>
P粉410239819P粉410239819385 天前478

全部回覆(1)我來回復

  • P粉575055974

    P粉5750559742023-09-04 09:47:34

    將您的第一個數組視為$datas變量,我們將使用foreach循環整個數組

    foreach($datas as $data) {
        $result[] = array('column' => $data['column']);
    }
    print_r($result);
    

    回覆
    0
  • 取消回覆