这就是我得到的......
$shop = array( array( first_name => "john",
last_name => "doe"
));
foreach($shop as $key => $value) {
foreach($value as $key2 => $value2) {
$shop[$key][$key2] = $shop[$key]['newname'];
unset($shop[$key][$key2]);
}}
print_r($shop);
哪个输出
Array ( [0] => Array ( ) )
答案 0 :(得分:0)
更改分配线(第6行)并使newname
动态化。如下所示:
...foreach ($value as $key2 => $value2) {
$newname = 'new_' . $key2;
$shop[$key][$newname] = $shop[$key][$key2];
unset($shop[$key][$key2]);
}...