homepage Welcome to WebmasterWorld Guest from 54.205.197.66
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Sorting Multidimensional Arrays
Sorting multidimensional arrays
Tourex




msg:3097567
 2:38 pm on Sep 26, 2006 (gmt 0)

Help!

I am trying to analyse stored customer enquiries by month and country of origin. The total enquiries for each country and month are contained in an array in the format...

$country[$x][$z]

...where $x is the month (1-12) and $z is a country code (1-200).

I need to list the contents of the array by month, in ascending order, and by the value of the country column, in descending order.

I have spent a day trying to get my head around the various array sort functions and failed miserably.

HELP please! thanks in anticipation.

 

jatar_k




msg:3097672
 3:36 pm on Sep 26, 2006 (gmt 0)

take a look at this

<?
$country[0] = array(5,98);
$country[1] = array(3,11);
$country[2] = array(2,199);
$country[3] = array(1,43);
$country[4] = array(4,126);

echo '<p><pre>before sort:<br>';
print_r($country);
echo '</pre>';

array_multisort($country,0);

echo '<p><pre>after sort:<br>';
print_r($country);
echo '</pre>';

?>

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved