我有一个数组:
$array['text6'] = array(
'elem2' => 'text2',
'elem3' => 'text3',
'elem4' => 'text4',
'elem5' => 'text5'
'elem6' => 'text6'
);
我希望将文本中的 text6关键词更改为其他关键词,例如:
$name_key = 'elem4';
// something action here
// and final array:
$array['text4'] = array(
'elem2' => 'text2',
'elem3' => 'text3',
'elem5' => 'text5'
'elem6' => 'text6'
);
我可以帮助你翻译。这篇文章涉及到IT技术。你需要更改105个数组,使它们呈现相同的方式。下面是一个例子:
$array['text6'] = array(
'elem2' => 'text2',
'elem3' => 'text3',
'elem4' => 'text4',
'elem5' => 'text5'
'elem6' => 'text6'
);
$array['othertext6'] = array(
'elem2' => 'othertext2',
'elem3' => 'othertext3',
'elem4' => 'othertext4',
'elem5' => 'othertext5'
'elem6' => 'othertext6'
);
我希望更改主键为第三个键(键 -> 'elem4'),并且它应该在每个数组中进行更改(数组之间的区别仅在于值,键始终相同):
$name_key = 'elem4';
// action...
$array['text4'] = array(
'elem2' => 'text2',
'elem3' => 'text3',
'elem5' => 'text5'
'elem6' => 'text6'
);
$array['othertext4'] = array(
'elem2' => 'othertext2',
'elem3' => 'othertext3',
'elem5' => 'othertext5'
'elem6' => 'othertext6'
);
我该怎么做呢?