0
array:4 [▼
0 => array:2 [▼
0 => "chrysanthemum.jpg"
1 => "http://site.loc/1"
]
1 => array:2 [▼
0 => "desert.jpg"
1 => "http://site.loc/2"
]
2 => array:2 [▼
0 => "hydrangeas.jpg"
1 => "http://site.loc/3"
]
3 => array:2 [▼
0 => "jellyfish.jpg"
1 => "http://site.loc/4"
]
]
如何在每個數組中將['img']和1重命名爲['link']?如何重命名多維數組中的匿名鍵
嘗試這樣的:
foreach($data as $array){
$array['img']=$array[0];
unset($array[0]);
$array['link']=$array[1];
unset($array[1]);
}
,但它不工作:C PHP確實有這個任務的功能?
'$ keys = ['img','link']; array_walk($ myArray,function(&$ value){$ value = array_combine($ keys,$ value);});'' –