FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Array_multisort help please
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Array_multisort help please [message #170282] Tue, 26 October 2010 15:45 Go to previous message
MikeB is currently offline  MikeB
Messages: 65
Registered: September 2010
Karma:
Member
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>";
?>
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: IT job
Next Topic: Php windows system(whois) not working
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 17:27:42 GMT 2024

Total time taken to generate the page: 0.03748 seconds