Change position of elements in an associative array in php -
i have associative array :
$headers= array ( [module_id] => module id [platform_id] => platform id [package_guid] => package guid [aggregate_package] => aggregate package [deld] => deld )
now wish change position ofpackage id @ top resemble :
$desired= array ( [package_guid] => package guid [module_id] => module id [platform_id] => platform id [aggregate_package] => aggregate package [deld] => deld )
i tried array_unshift
method not works in case associative array.
unset($headers['package_guid']); array_unshift($headers, 'package_guid');
how can achieve it? thanks.
unset($headers['package_guid']); array_unshift($headers, array('package_guid' => 'package guid'));