亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

通過“helper”函數創建 key => value 數組

通過“helper”函數創建 key => value 數組

PHP
暮色呼如 2023-09-15 10:40:45
我有一個具有以下值的二維數組:  [    'id' => 12,    'title' => 'the title', //and a few other key => value    ],        [    'id' => 13,    'title' => 'the title 13', // and a few other key => value    ],...最后,我需要一個只有id 和 title的多維數組[ $item['id'] => $item['title'], ...]通常,我會做一個簡單的 foreach 來實現這一點,但我現在想使用 php 函數。我已經這樣做了,但是有正確的方法嗎?$list = array_combine(array_column($list_forms, 'id'), array_column($list_forms, 'title'));
查看完整描述

1 回答

?
慕仙森

TA貢獻1827條經驗 獲得超8個贊

第三參數是:array_column

$list?=?array_column($list_forms,?'title',?'id');


查看完整回答
反對 回復 2023-09-15
  • 1 回答
  • 0 關注
  • 95 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號