PHP - Sorting Then Printing Multidimension Array
<?php
$menu = array( '22' => array ( 'title'=>'Businesses' ,'busstype'=>array( 5=>'Printers' ,2=>'Bookshops' ,6=>'Publishers' ,8=>'Uniform Distributors' ) ) ,21 => array ( 'title'=>'Academic' ,'busstype'=>array ( 5=>'Academy' ,6=>'Primary' ,7=>'Polytechnic' ,11=>'University' ) ) ,'Events' => array ( 'title'=>'Events' ,'busstype'=>array ( 3=>'Music' ,4=>'Road shows' ,6=>'Sports' ,6=>'Yoga' ) ) ) ; I have a dynamically created menu as above. How would i sort on the 'busstype' homogenously and print it while maintaing the key. Results should be like <a href="search.php?listing=21&busstype=5">Academy</a> <a href="search.php?listing=22&busstype=2">Bookshops</a> ....... <a href="search.php?listing=Events&busstype=6">Yoga</a> ?> Similar TutorialsHello, I've been curious why the following won't work. Could anyone show me what I am doing wrong. The code is to find the TLD in a URL. Code: [Select] $a[] = parse_url( 'www.example.com' ); $tld_arr = array ( 'com', 'net', etc...); for ($i=0; $i<count($this->a); $i++) { if (in_array ( $this->a[$i]['host'], $tld_arr) ) < This is what I'm curious about { //do something } // do something else } Thank you I'm having an issue with building a multidimensional array via a for (....) the array should look like the example any help would be much, much appreciated thanks siouxx array ["username"] = "steve" array ["item"] = "12345" array "model" = "some model" "quantity" = "36.2" "details" array 0 = "detail 1" 1 = "detail 2" 2 = "detail 3" ["username"] = "steve" array ["item"] = "000257" array "model" = "some other model" "quantity" = "77.8" "details" array 0 = "detail 1" 1 = "detail 2" ["username"] = "bob" array ["item"] = "45678" array "model" = "other model" "quantity" = "99.5" "details" array 0 = "detail 1" 1 = "detail 2" 2 = "detail 3" 3 = "detail 3" the array return by sql looks like this Array ( => Array ( [id_prod] => 6 [id_tipo] => CPT [marca] => HP [modello] => Pavilion p6-200 [prezzo] => 599.00 [desc] => Computer da Tavolo [chiave] => 32 [utente] => steve [qta] => 1 [indata] => 2011-10-10 16:32:20 [dettaglio] => HD 320GB - RAM 4GB - Scheda audio 5.1 ) [1] => Array ( [id_prod] => 6 [id_tipo] => CPT [marca] => HP [modello] => Pavilion p6-200 [prezzo] => 599.00 [desc] => Computer da Tavolo [chiave] => 31 [utente] => steve [qta] => 1 [indata] => 2011-10-10 16:32:20 [dettaglio] => Intel Core i3-550 (3.20GHz, 4MB L3) I have whiled my way through any number of forums and help pages so far. However, since I am not quite comfortable yet with PHP, I am not sure which option I have been given would be the right one. What I am trying to do: Create the source for a set of drop-down menus. The dropdown menu has columns, and then a H2 and P that go in each column, in varied numbers, so you have column1, h2 p; h2 p; h2 p column2, h2 p; h2 p etc....make sense? I am using an MySQL table as source so I can have a little CMS dashboard where I can change these and other values on the fly. So I have a MySQL table where I have a field that identifies the column (page name), and then values to fill the h2 and p tags. I.E.: page_name, content_title, content_text The idea, therefore, is to use PHP to figure out what the column names (that are repeated) in the mysql table and then create the dropdown based on the value in the subsidiary fields. Output is as a string in a variable value that is output via return (); My best estimation of how to do this is to use php to create a multidimensional array from the query result, where the first column is the page_name, followed by an array, the array being the remainder of the information. Based on information scrounged from other sources, I have come up with this so far: $query = "SELECT * FROM tbl_mainmenu WHERE mainmenu_type = '$mmtype'"; // what the query is $result = mysql_query ($query, $dbc); // connect to database and run query, setting the the result to dummy array variable '$result' // establish the multidimensional array $mmcontent_array = array (); //create the array where the values are content page and associated values in an array per each content page while ($result = mysql_fetch_assoc ()) { $page_name = $result['content_page']; $mmcontent_array['content_page'] = $result; } foreach ($mmContent_array[] as $key=>$value) { foreach () { $tmpelements[] = '<div class="col_2"><h2>' . $element[content_title] . "</h2>\n<p>" . $element[content_text] . "</p>\n</div>"; $elements = implode("\n",$tmpelements) . "\n" } $tmp[] = '<li><a href="#" class="drop">Products</a><!-- Begin Products Item -->\n<div class="dropdown_2columns"><!-- Begin 2 columns container -->' . $elements . 'whatever tags will close this') } Am I even in the ballpark? I am not sure which way to nest the foreach ()'s. The example I was working from used echo ()'s, and I am not sure if using $variable = implode () makes the task different. As a start, I am just wondering if I am creating the multidimensional array correctly? i have an array from a database that looks like this (below) but what i want is for the array to be sorted assedningly by the start position so the team with start position 1 will be 1st and so on...if anyone can help me on what i should do please...thank you Code: [Select] Array ( [1] => Array ( [team_name] => A Team [team_nationality] => British [start_position] => 2 ) [2] => Array ( [team_name] => B Team [team_nationality] => British [start_position] => 1 ) [3] => Array ( [team_name] => C Team [team_nationality] => British [start_position] => 4 ) [4] => Array ( [team_name] => B Team [team_nationality] => British [start_position] => 3 ) ) I have an array that looks like this... Code: [Select] Array ( [0] => Array ( [0] => 2 [1] => Dylan Cross ) [1] => Array ( [0] => 5 [1] => Bob Smith ) [2] => Array ( [0] => 1 [1] => Sarah Park ) [3] => Array ( [0] => 7 [1] => Jane Knowles ) [4] => Array ( [0] => 6 [1] => Harry Hill ) [5] => Array ( [0] => 3 [1] => Jack Rock ) ) How do I sort this array so it is ordered alphabetically by the names so the result will be... Code: [Select] Array ( [0] => Array ( [0] => 5 [1] => Bob Smith ) [1] => Array ( [0] => 2 [1] => Dylan Cross ) [2] => Array ( [0] => 6 [1] => Harry Hill ) [3] => Array ( [0] => 3 [1] => Jack Rock ) [4] => Array ( [0] => 7 [1] => Jane Knowles ) [5] => Array ( [0] => 1 [1] => Sarah Park ) ) Thanks How to sort PHP2d Array using upon key. eg. I have a array of $users[0]['name'] = "abc" $users[0]['age'] = "12" $users[0]['sex'] = "M"; $users[1]['name'] = "xyz" $users[1]['age'] = "15" $users[1]['sex'] = "M"; $users[2]['name'] = "pqr" $users[2]['age'] = "16" $users[2]['sex'] = "F"; Now I have to sort in on age or 'sex', Hello, i need some help with sorting arrays by it's value. lets say i want to have two different html tables listing the employees and another for the managers, then i want to sort them by Group ID's: Etc: Workers as the key / 1 as the value. Groups: Workers => 1 Managers => 2 Workers Group ID John 1 Peter 1 Lance 1 Managers Group ID Carol 2 Greg 2 Brian 2 How can i do this? The following code works, but I need to take it a step further and I'm not sure how. What I'd like to do is sort the output so the highest point totals get printed first (along with the associated information). Can anyone help? Here's the site: http://www.beat-the-spread.net/seasontotals.php Here's the code: Code: [Select] $i=1; $w=1; $result = mysql_query( " SELECT team_name, owner FROM teams" ); while ($row = mysql_fetch_array($result)) { echo "<tr>\n", "</td><td>", $row['owner'], "</td><td>", $row['team_name']; $result1 = mysql_query( " SELECT bye, owner_pts FROM schedule WHERE team = $i"); $num_rows = mysql_num_rows($result1); while ($row1 = mysql_fetch_array($result1)) { $totalpts = $totalpts + $row1['owner_pts']; if (empty($row1['bye'])) { echo "</td><td>", $row1['owner_pts'], "</tr>\n"; } else { echo "</td><td>","0","</tr>\n"; } } while ($num_rows<=16) { echo "</td><td>","","</tr>"; $num_rows++; } echo "</td><td>","$totalpts","</tr>"; $totalpts=0; $w++; $i++; } echo "</table>\n"; mysql_close($con); Thanks! I have the following php array structure and couldnot able to sort it according to the overall points. My code is reading an xml file using simplexml. Any help would be appreciated. Array ( => SimpleXMLElement Object ( [played] => 0 [won] => 0 [drawn] => 0 [lost] => 0 [overallpoints] => 0 ) [1] => SimpleXMLElement Object ( [played] => 6 [won] => 3 [drawn] => 0 [lost] => 3 [overallpoints] => 9 ) [2] => SimpleXMLElement Object ( [played] => 3 [won] => 1 [drawn] => 0 [lost] => 2 [overallpoints] => 3 ) [3] => SimpleXMLElement Object ( [played] => 0 [won] => 0 [drawn] => 0 [lost] => 0 [overallpoints] => 0 ) [4] => SimpleXMLElement Object ( [played] => 2 [won] => 1 [drawn] => 0 [lost] => 1 [overallpoints] => 3 ) } I am attempting to sort an array by price but cannot seem to get php to do this. Below is the array I am attempting to sort by the value ~ price: Array ( [http://pdt.tradedoubler.com/click?a(1774061)p(19045)prod(550992137)ttid(5)url(http%3A%2F%2Fwww.halfords.com%2Fwebapp%2Fwcs%2Fstores%2Fservlet%2Fproduct_storeId_10001_catalogId_10151_categoryId_165488_productId_561801_langId_-1%3Fsource%3Dtd)] => Array ( [logo] => nc0iicjxmq.gif [stock] => In Stock In Stock [price] => 14.99 [delivery] => 4.99 [url] => http://pdt.tradedoubler.com/click?a(1774061)p(19045)prod(550992137)ttid(5)url(http%3A%2F%2Fwww.halfords.com%2Fwebapp%2Fwcs%2Fstores%2Fservlet%2Fproduct_storeId_10001_catalogId_10151_categoryId_165488_productId_561801_langId_-1%3Fsource%3Dtd) [mname] => Halfords ) [http://pdt.tradedoubler.com/click?a(1774061)p(19045)prod(767538675)ttid(5)url(http%3A%2F%2Fwww.halfords.com%2Fwebapp%2Fwcs%2Fstores%2Fservlet%2Fproduct_storeId_10001_catalogId_10151_categoryId_165497_productId_780417_langId_-1%3Fsource%3Dtd)] => Array ( [logo] => nc0iicjxmq.gif [stock] => In Stock In Stock [price] => 19.99 [delivery] => 4.99 [url] => http://pdt.tradedoubler.com/click?a(1774061)p(19045)prod(767538675)ttid(5)url(http%3A%2F%2Fwww.halfords.com%2Fwebapp%2Fwcs%2Fstores%2Fservlet%2Fproduct_storeId_10001_catalogId_10151_categoryId_165497_productId_780417_langId_-1%3Fsource%3Dtd) [mname] => Halfords ) [http://pdt.tradedoubler.com/click?a(1774061)p(19045)prod(254177017)ttid(5)url(http%3A%2F%2Fwww.halfords.com%2Fwebapp%2Fwcs%2Fstores%2Fservlet%2Fproduct_storeId_10001_catalogId_10151_categoryId_165497_productId_271987_langId_-1%3Fsource%3Dtd)] => Array ( [logo] => nc0iicjxmq.gif [stock] => In Stock In Stock [price] => 15.00 [delivery] => 2.99 [url] => http://pdt.tradedoubler.com/click?a(1774061)p(19045)prod(254177017)ttid(5)url(http%3A%2F%2Fwww.halfords.com%2Fwebapp%2Fwcs%2Fstores%2Fservlet%2Fproduct_storeId_10001_catalogId_10151_categoryId_165497_productId_271987_langId_-1%3Fsource%3Dtd) [mname] => Halfords ) [http://pdt.tradedoubler.com/click?a(1774061)p(19045)prod(550992487)ttid(5)url(http%3A%2F%2Fwww.halfords.com%2Fwebapp%2Fwcs%2Fstores%2Fservlet%2Fproduct_storeId_10001_catalogId_10151_categoryId_165488_productId_561805_langId_-1%3Fsource%3Dtd)] => Array ( [logo] => nc0iicjxmq.gif [stock] => In Stock In Stock [price] => 4.99 [delivery] => 2.99 [url] => http://pdt.tradedoubler.com/click?a(1774061)p(19045)prod(550992487)ttid(5)url(http%3A%2F%2Fwww.halfords.com%2Fwebapp%2Fwcs%2Fstores%2Fservlet%2Fproduct_storeId_10001_catalogId_10151_categoryId_165488_productId_561805_langId_-1%3Fsource%3Dtd) [mname] => Halfords ) [http://pdt.tradedoubler.com/click?a(1774061)p(19045)prod(18823539)ttid(5)url(http%3A%2F%2Fwww.halfords.com%2Fwebapp%2Fwcs%2Fstores%2Fservlet%2Fproduct_storeId_10001_catalogId_10151_categoryId_165488_productId_155878_langId_-1%3Fsource%3Dtd)] => Array ( [logo] => nc0iicjxmq.gif [stock] => In Stock In Stock [price] => 18.00 [delivery] => 4.99 [url] => http://pdt.tradedoubler.com/click?a(1774061)p(19045)prod(18823539)ttid(5)url(http%3A%2F%2Fwww.halfords.com%2Fwebapp%2Fwcs%2Fstores%2Fservlet%2Fproduct_storeId_10001_catalogId_10151_categoryId_165488_productId_155878_langId_-1%3Fsource%3Dtd) [mname] => Halfords ) [http://pdt.tradedoubler.com/click?a(1774061)p(19045)prod(580777789)ttid(5)url(http%3A%2F%2Fwww.halfords.com%2Fwebapp%2Fwcs%2Fstores%2Fservlet%2Fproduct_storeId_10001_catalogId_10151_categoryId_242553_productId_385055_langId_-1%3Fsource%3Dtd)] => Array ( [logo] => nc0iicjxmq.gif [stock] => In Stock In Stock [price] => 21.99 [delivery] => Free Shipping [url] => http://pdt.tradedoubler.com/click?a(1774061)p(19045)prod(580777789)ttid(5)url(http%3A%2F%2Fwww.halfords.com%2Fwebapp%2Fwcs%2Fstores%2Fservlet%2Fproduct_storeId_10001_catalogId_10151_categoryId_242553_productId_385055_langId_-1%3Fsource%3Dtd) [mname] => Halfords ) [http://pdt.tradedoubler.com/click?a(1774061)p(19045)prod(18823503)ttid(5)url(http%3A%2F%2Fwww.halfords.com%2Fwebapp%2Fwcs%2Fstores%2Fservlet%2Fproduct_storeId_10001_catalogId_10151_categoryId_165497_productId_217063_langId_-1%3Fsource%3Dtd)] => Array ( [logo] => nc0iicjxmq.gif [stock] => In Stock In Stock [price] => 24.99 [delivery] => Reserve and Collect [url] => http://pdt.tradedoubler.com/click?a(1774061)p(19045)prod(18823503)ttid(5)url(http%3A%2F%2Fwww.halfords.com%2Fwebapp%2Fwcs%2Fstores%2Fservlet%2Fproduct_storeId_10001_catalogId_10151_categoryId_165497_productId_217063_langId_-1%3Fsource%3Dtd) [mname] => Halfords ) [http://track.webgains.com/click.html?wgcampaignid=72782&wgprogramid=2730&product=1&wglinkid=90005&productname=Continental+Sport+Contact+Road%2FHybrid+Bicycle+Tyre&wgtarget=http://www.awcycles.co.uk/brands/Continental/Sport_Contact_Road/Hybrid_Bicycle_Tyre] => Array ( [logo] => 8yfd588e8t.jpg [stock] => In Stock In Stock [price] => 21.99 [delivery] => [url] => http://track.webgains.com/click.html?wgcampaignid=72782&wgprogramid=2730&product=1&wglinkid=90005&productname=Continental+Sport+Contact+Road%2FHybrid+Bicycle+Tyre&wgtarget=http://www.awcycles.co.uk/brands/Continental/Sport_Contact_Road/Hybrid_Bicycle_Tyre [mname] => AW Cycles ) ) Any help would be much appreciated. Thanks Simon Hi does anyone know how to sort the array below (files) echo "<br /><br /><b>Favorites</b><br />"; $d = dir("/mnt/disk/v1/mfiles/downloads/music/favorites/"); while (false !== ($entry = $d->read())) { if($entry!='.' && $entry!='..') { if(is_dir($entry)) { echo 'true'; $subdirs = get_leaf_dirs($entry); if ($subdirs) $array = asort(array_merge($array, $subdirs)); else $array[] = $entry; } echo '<a href="/scripts/download.php?actie=favorites/'.$entry.'" title="Click here to download this song" target="_blank">'.left($entry,(strlen($entry)-4)).'</a><br />'; } } $d->close(); Hi - I'm modifying some PHP code that someone else wrote. Below is a snippet of code that basically takes mp3 files files within all the folders in a directory, and creates an RSS feed. In the resulting feed, the files are intermingled in date order. Instead, I'd like them sorted by the directory that they are in. So, if there are files in these directories: 01-First 02-Second 03-Third I'd like all the files in the "01-First" directory to come before the "02-Second" directory and so on. Within each directory the files can be sorted as they currently are. The name of the directory in the code is signified by $dir_name. I tried sort() and array_multisort() but I couldn't get either of them to work the way I wanted. Any thoughts? if ($url_params['mode'] == 'rss2') { print getRSSHeader('UTF-8', $device, $vm_config, $vm_name, $web_master, $logo_image,$context); $mailboxes = array(); if ($dev_dir = @opendir($VMHome . $device)) { //might fail if mailbox has not received first message yet while ($f = readdir($dev_dir)) { if (!eregi("tmp","$f") && !eregi("\.+","$f") && !eregi("Exclude-From-CD", "$f")) { //skip tmp directory and Exclude-From-CD Directories array_push($mailboxes,"$f"); #collect all existing mailboxes } } array_multisort($mailboxes, SORT_DESC); foreach ($mailboxes as $mailbox) { $files=array(); $dir_name = $VMHome . $device . '/'. $mailbox .'/'; $dir = opendir($dir_name); while ($f = readdir($dir)) { if (eregi("\.txt",$f)){ #if filename matches .txt in the name array_push($files,"$f"); #push into $files array } } foreach($files as $file){ $props = getProperties($dir_name, $file); $uid = getMP3File($dir_name, $file, $props, $device, $mailbox, $vm_config, $vm_name,$context); print getRSSItem ($props, $uid, $dir_name, $device, '/' . $mailbox . '/', $context); } } } print ' </channel> </rss>'; } Hello! I have a 2D array that look as follows: $test["name"][0] = "arnold"; $test["name"][1] = "nate"; $test["name"][2] = "steve"; $test["id"][0] = 2; $test["id"][1] = 0; $test["id"][2] = 1; This means arnold has an ID of 2, nate has an ID of 0 and steve has an ID of 1. Now I want to sort the array based on the ID value, so I want to achieve the following result: $test["name"][0] = "nate"; $test["name"][1] = "steve"; $test["name"][2] = "arnold"; How would I achieve this? Help much appreciated. Here is my code...
<?php $to = "email@email.com"; //obviously not real $from = "noreply@domain.com"; //obviously not real $firstName = $_REQUEST['firstName']; $headers = "From: $from"; $subject = "Product Sheet Request"; /* $fields = array(); $fields{"firstName"} = "firstName"; $fields{"lastName"} = "lastName"; $fields{"email"} = "email"; $fields{"phone"} = "phone"; $fields{"affiliation"} = "affiliation"; $fields{"interest"} = "interest"; $fields{"productSheets"} = "productSheets"; $fields{"referredBy"} = "referredBy"; $fields{"additional"} = "additional"; */ $firstName = $_REQUEST['firstName']; $lastName = $_REQUEST['lastName']; $email = $_REQUEST['email']; $phone = $_REQUEST['phone']; $affiliation = $_REQUEST['affiliation']; $interest = $_REQUEST['interest']; if($interest == 'inclusion'){ $interest = 'Evaluating for inclusion in product'; } elseif($interest == 'general'){ $interest = 'Interested in the technology generally'; } elseif($interest == 'research'){ $interest = 'Performing market research'; } elseif($interest == 'solutions'){ $interest = 'Looking for competitive solutions'; } $referredBy = $_REQUEST['referredBy']; $additional = $_REQUEST['additional']; $productSheets[] = $_REQUEST['productSheets']; $sheets = print_r($productSheets); /* $body = "A user has requested product sheet(s). Please review their information and respond:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); } */ $body = "A user has requested product sheet(s). Please review their information and respond:\n First Name: ".$firstName."\r Last Name: ".$lastName."\r Email: ".$email."\r Phone Number: ".$phone."\r Affiliation: ".$affiliation."\r Reason for Interest: ".$interest."\r Referred By: ".$referredBy."\r Additional Questions/Comments: ".$additional."\r Product Sheet(s) Requested: ".$sheets."\n "; $send = mail($to, $subject, $body, $headers); ?>I'm not quite sure how to display the values of the $productSheets array in the email message. Everytime it either outputs "Array" or "1". The $productSheets array is from a checkbox on a form. Everything else is working as expected. Hello. I am just trying to sort an array alphabetically. Here's the code I'm using: function GetAssocCharities($registrationNo) { $db = ConnectionString::ConnectTo_www_ago_mo_gov_data(); $sqlstring = "SELECT * FROM charityPartners where RegistrationNo LIKE '$registrationNo' ORDER BY Name"; $results = @mysql_query($sqlstring); $org = null; while ($resultArray = mysql_fetch_array($results)) { $temp = new Registrants($resultArray['ARegNoFormatted'], $resultArray); $org[] = $temp; } return asort($org); } When I try to loop through the array using a foreach loop, I get an error that Invalid argument supplied for foreach(). Here's my foreach loop: $lstCharities = OrgQueries::GetAssocCharities($registrant->RegNoFormatted); foreach($lstCharities as $c) { //dom something here } I'm sure its something with not understanding list v array or something or that nature, but I'm not having much luck figuring it out with google. Thanks! I can't quite figure out how to sort this array the way I want. I have tried "array_multisort" but can only get one demension to sort. Here is the array... $catagory = array( array('Catagory 1', 8, array('Sub Catagory 1 Item 1', 8), array('Sub Catagory 1 Item 2', 9), array('Sub Catagory 1 Item 3', 7), array('Sub Catagory 1 Item 4', 6), ), array('Catagory 2', 10, array('Sub Catagory 2 Item 1', 6), array('Sub Catagory 2 Item 2', 5), array('Sub Catagory 2 Item 3', 9), array('Sub Catagory 2 Item 4', 10), ), ); I would like the top catagories sorted in desending order and all the subcatagories sorted in desending order. The result would sort like this... Catagory 2 = 10 Sub Catagory 2 Item 4 = 10 Sub Catagory 2 Item 3 = 9 Sub Catagory 2 Item 1 = 6 Sub Catagory 2 Item 2 = 5 Catagory 1 = 8 Sub Catagory 1 Item 2 = 9 Sub Catagory 1 Item 1 = 8 Sub Catagory 1 Item 3 = 7 Sub Catagory 1 Item 4 = 6 How can I achieve this. Thanks for any help. Hi All I'm new to php and I have a multidimensional array set up which I need to sort for a results list from an assessment. The array is $gradout['name']['userid']=score. I need to sort the array by score in a decending order. ['name'] is a string and ['userid'] is a numeric. I've tried looking at the php manual but It's just confusing me. Can anyone explain to me in laymans terms what I need to do and why. Hi. I have a multidimensional array and i need sort it by two different key. I've tried almost every sort function but no chance. Code: [Select] Array ( [0] => Array ( [0] => 1 [id] => 1 [11] => this is test [main_txt] => this is test [12] => 943965420 [add_time] => 943965420 [13] => 1323356400 [add_date] => 1323356400 ) [1] => Array ( [0] => 3 [id] => 3 [11] => another test [main_txt] => another test [12] => 943965120 [add_time] => 943965120 [13] => 1323702000 [add_date] => 1323702000 ) [2] => Array ( [0] => 32 [id] => 32 [11] => oppss one more test [main_txt] => oppss one more test [12] => 943944900 [add_time] => 943944900 [13] => 1323702000 [add_date] => 1323702000 ) [3] => Array ( [0] => 5 [id] => 5 [11] => okay, this is last one. Seriously [main_txt] => okay, this is last one. Seriously [12] => 943937160 [add_time] => 943937160 [13] => 1323615600 [add_date] => 1323615600 ) ) I need sort by add_date(Newer to Older) first then add_time(Later to Earlier) later. I hope i made my self clear. I have an array and when i do a print_r(), i get this: Array ( => Array ( [path] => 1 [order] => 2 ) [1] => Array ( [path] => 2 [order] => 2 ) [2] => Array ( [path] => 3 [order] => 1 ) ) I want to sort it so that the array with an order of 1 is at the front, i.e. that last array in this case. I tried asort but that didnt do anything... I have an array of type Code: [Select] Array ( [2] => Array ( [name] => Shelby Baptist Medical Ctr [city] => Alabaster ) [1] => Array ( [name] => Andalusia Regional Hospital [city] => Andalusia ) [0] => Array ( [name] => Long Term Hospital of Anniston [city] => Anniston )) How can sort the keys of an array but there content remains the same so that they are like Code: [Select] Array ( [0] => Array ( [name] => Shelby Baptist Medical Ctr [city] => Alabaster ) [1] => Array ( [name] => Andalusia Regional Hospital [city] => Andalusia ) [2] => Array ( [name] => Long Term Hospital of Anniston [city] => Anniston )) Can someone please point me if there is any func. for this |