This one is baffling me at the moment, and I'm a little confused as to what it is doing.
So I have a multi directional array:
$h_info[69993] = array('price' => '1.00', 'url' => 'url', 'rating' => '4');
$h_info[85398] = array('price' => '3.00', 'url' => 'url', 'rating' => '2');
$h_info[34394] = array('price' => '9.00', 'url' => 'url', 'rating' => '0');
Now I have the following while loop
foreach ($h_info as $row) {
foreach ($row as $key => $value){
${$key}[] = $value; //Creates $price, $url... arrays.
}
}
array_multisort($price, SORT_ASC, $h_info);
Now this works, but it removes the $h_info id from the array and outputs
Array
(
[0] => Array
(
[price] => 39
[url] => url,
[rating] => 4.5
)
...
But i need the ID to stay - when I do this:
foreach ($h_info as $row => $id) {
foreach ($row as $key => $value){
${$key}[] = $value; //Creates $price, $url... arrays.
}
}
array_multisort($price, SORT_ASC, $h_info);
The sort no longer works, but outputs the array correctly:
Array
(
[69993] => Array
(
[price] => 39
[url] => url,
[rating] => 4.5
)
...