I have an array like this.
array('root'=> array(
'auth'=>'stringKey',
'version'=>'4057',
'...'=>'...'
)
)
Now I want to remove the outer array and root
key and so I get array like below. i.e reduce it to one dimensional array
array(
'auth'=>'stringKey',
'version'=>'4057',
'...'=>'...'
)
$array = array(
'root'=> array(
'auth'=>'stringKey',
'version'=>'4057',
'...'=>'...'
)
);
print_r($array['root']);
Try this it is work for me
<?php $myarr = array('root'=> array(
'auth'=>'stringKey',
'version'=>'4057',
'...'=>'...'
)
);
$array = call_user_func_array('array_merge',$myarr);
print_r($array);
/*
output
Array
(
[auth] => stringKey
[version] => 4057
[...] => ...
)
*/
?>
You can overwrite the existing variable with the :
$myarray = array('root'=> array(
'auth'=>'stringKey',
'version'=>'4057',
'...'=>'...'
)
)
$myarray = $myarray['root'];