我有以下數(shù)據(jù)結構:$campaigns =Array([0] => Array ( [subject] => cca-cpg )[1] => Array ( [subject] => cleanup-cpg )[2] => Array ( [subject] => gas-cpg )[3] => Array ( [subject] => pollinators-cpg ))我想結束的是:$campaigns = ['cca-cpg','clean_up-cpg','gas-cpg','pollinators-cpg'];this will work:$newCampaigns=[];for($i=0;$i<count($campaigns);$i++){ array_push($newCampaigns,$campaigns[$i]['subject'];}但我想知道是否有更好的方法來做到這一點。數(shù)據(jù)直接來自mysql數(shù)據(jù)庫
1 回答

慕娘9325324
TA貢獻1783條經(jīng)驗 獲得超4個贊
有適合array_column()
你的功能:
$newCampaigns?=?array_column($campaigns,?'subject');
- 1 回答
- 0 關注
- 118 瀏覽
添加回答
舉報
0/150
提交
取消