Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/142616-help-sorting-multiple-dimension-arrays/
Share on other sites

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.