tran_dinh_ba Posted January 27, 2009 Share Posted January 27, 2009 Hi all, I have multiple dimension arrays shown as below: $arr[] = array("m1"="one","m2"=>"two","m3"=>"three"); $arr[] = array("m1"="zone","m2"=>"what","m3"=>"help"); $arr[] = array("m1"=>"show","m2"=>"me","m3"=>"with"); $arr[] = array("m1"="ABC","def"=>"adfdf","m3"=>"ewwww"); $arr[] = array("m1"="55555","m2"=>"7777","m3"=>"yyyy"); $arr[] = array("m1"=>"rrrr","m2"=>"wwww","m3"=>"rfrr"); $arr[] = array("m1"="fff","m2"=>"vvcv","m3"=>"sdsds"); $arr[] = array("m1"="tyty","m2"=>"yuyu","m3"=>"oioi"); $arr[] = array("m1"=>"3434","m2"=>"4545","m3"=>"45454"); Any ones can help me to display the results of m1,m2,m3 and sort by m1 ASCENDING AND LIMIT DISPLAY 3 RECORDS PER PAGE? Many thanks. Tim Quote Link to comment https://forums.phpfreaks.com/topic/142616-help-sorting-multiple-dimension-arrays/ Share on other sites More sharing options...
RichardRotterdam Posted January 27, 2009 Share Posted January 27, 2009 I read the word limit and records. Makes me think you are fetching it from a database. Are you using a database, if you are why not sort it before you put it in arrays? otherwise look into array_multisort http://nl.php.net/array_multisort Quote Link to comment https://forums.phpfreaks.com/topic/142616-help-sorting-multiple-dimension-arrays/#findComment-747489 Share on other sites More sharing options...
tran_dinh_ba Posted January 27, 2009 Author Share Posted January 27, 2009 These data are drawm from a table which has only 2 columns: col1,col2 and col1 contain the field names, and col2 contains the values of col1. After fetching these records, I put them into the arrays in the format that I already posted. From those arrays, then I need to do some kind of sorting and displaying the results in the table show as following col1,col2,col3 value1,value2,value3 value1,value2,value3, and so on Quote Link to comment https://forums.phpfreaks.com/topic/142616-help-sorting-multiple-dimension-arrays/#findComment-747492 Share on other sites More sharing options...
tran_dinh_ba Posted January 29, 2009 Author Share Posted January 29, 2009 Thank you for replying. I visited the site you mentioned and got my function working. Thanks. Ba Quote Link to comment https://forums.phpfreaks.com/topic/142616-help-sorting-multiple-dimension-arrays/#findComment-749532 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.