function sortpm($parameters){
if(strpos($parameters,"&")!==false){
foreach(explode("&",$parameters) as $pmsplit){
$key = explode("=",$pmsplit)[0];
$value = explode("=",$pmsplit)[1];
$fields[]=[$key=>$value];
}
$parameters = ksort($fields);
}else{
$parameters = $parameters;
}
print_r($parameters);
}
when i get sortpm("z=4&a=2"); array are not sorted by keys
i want this output: Array ( [a] => 2[z] => 4 )
1when I run your function with the provided input. Also, you should probably use parse_str().