looking for an array sorting function.. just not sure which one.. and how yet

From: Date: Sun, 11 Mar 2012 00:42:58 +0000
Subject: looking for an array sorting function.. just not sure which one.. and how yet
Groups: php.general 
Request: Send a blank email to php-general+get-316974@lists.php.net to get a copy of this message
Hi Everyone I am newbie enough with the terminology around PHP arrays that I am slow to wrap my head around what I know is in the docs (what i am reading)... but just can't identify yet. I think it will be faster if someone can translate for me in terms of my question: I make an array by building up its members form the results of a db call, like so: foreach ($query->result() as $row) { $arr_cTree[$row->cID] = array($row->cPcID, $row->cL, $row->cName, $row->cSeg, $row->cSort); } I have that array's members' values displaying on an HTML page fine by making recursive function calls to grab the children of each parent member found.. but the order those array members are displayed on the page is not what I want (it seems to be displaying according to the order the rows are found in the db). To remedy, I want to sort on the last value in the array which is the value of each array member. (If I said that right.) IOW, I want to sort my $arr_cTree array by the decimal values stored in $row->cSort ($arr_cTree[[4]), before I then display on the page. Can someone point me to the array sorting function you think is suited to this job.. and perhaps give me an example in pseudo code if that helps make it more clear in this case. Thanks! -Govinda

« previous php.general (#316974) next »