I'm having a problem with using the array_multisort() function.
One key is a string consisting entirely of numbers and the function
reads that as an index and reindexes the array, thus destroying the
actual values.
What I'm trying to achieve is to make sure that the second dimension is
always consistently sorted alphabetically. Eg. The key "siccles" should
always precede the key "UpperKEES' when both are present.
Thanks,
MikeB
This is what I have:
<?php
$array1 = array(
"10453"=> array(
"UpperKEES"=> array(
"ts"=>"1,2,3",
"score"=>"9854")
)
);
$array1["10453"]["siccles"] = array("ts"=>"4,5,6","score"=>"9854");
$array1["20095"]["siccles"] = array("ts"=>"3,5,4","score"=>"4751");
$array1["32095"]["siccles"] = array("ts"=>"3,5,4","score"=>"4751");
$array1["32095"]["UpperKEES"] = array("ts"=>"3,5,4","score"=>"4751");
$array1["45695"]["UpperKEES"] = array("ts"=>"3,5,4","score"=>"4751");
$array1["45695"]["siccles"] = array("ts"=>"3,5,4","score"=>"4751");
$array1["53216"]["siccles"] = array("ts"=>"3,5,4","score"=>"4751");
$array1["53216"]["UpperKEES"] = array("ts"=>"3,5,4","score"=>"4751");
$array1["66595"]["UpperKEES"] = array("ts"=>"3,5,4","score"=>"4751");
$array1["75489"]["UpperKEES"] = array("ts"=>"3,5,4","score"=>"4751");
$array1["89654"]["UpperKEES"] = array("ts"=>"3,5,4","score"=>"4751");
$array1["89654"]["siccles"] = array("ts"=>"3,5,4","score"=>"4751");
$array1["99095"]["siccles"] = array("ts"=>"3,5,4","score"=>"4751");
$array1["99095"]["UpperKEES"] = array("ts"=>"3,5,4","score"=>"4751");
$array1["99995"]["siccles"] = array("ts"=>"3,5,4","score"=>"4751");
array_multisort($array1,SORT_REGULAR);
echo "<h2>Array 1 sorted var_dump</h2><br /><pre>";
var_dump($array1);
echo "</pre>";
?>
|