I have an array:
$array['text6'] = array(
'elem2' => 'text2',
'elem3' => 'text3',
'elem4' => 'text4',
'elem5' => 'text5'
'elem6' => 'text6'
);
And I would like to change, for example text6 key with other key in that way:
$name_key = 'elem4';
// something action here
// and final array:
$array['text4'] = array(
'elem2' => 'text2',
'elem3' => 'text3',
'elem5' => 'text5'
'elem6' => 'text6'
);
How I can do it? I have 105 arrays and I need to change every array in the same way, so when array looks that:
$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'
);
And I would like to change main key with key number three (key -> 'elem4'), it should make in every array (different beetwen arrays is only in value, keys are always the same):
$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'
);
How I can do it?