Current location: Hot Scripts Forums » Programming Languages » PHP » working of array_mutlisort() in the following...

working of array_mutlisort() in the following...

Reply
  #1 (permalink)  
Old 11-09-09, 03:50 AM
karthikanov24 karthikanov24 is offline
Newbie Coder
 
Join Date: Sep 2009
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
working of array_mutlisort() in the following...

hi

In the following code,array_mutisort() is used....
Code:
<?php
$a=array(0=>array('catid'=>17,'catparentid'=>10,'catname'=>'mercedes'),1=>array('catparentid'=>12,'catid'=>14,'catname'=>'volvo'),2=>array('catid'=>16,'catparentid'=>11,'catname'=>'whostock'));
print_r($a);
echo "<hr>";
array_multisort($a);
print_r($a);
?>
In the array of key 1, 'catparentid' is the first key,inside...unlike others....

when i run this code,i get output as:

Array ( [0] => Array ( [catid] => 17 [catparentid] => 10 [catname] => mercedes ) [1] => Array ( [catparentid] => 12 [catid] => 14 [catname] => volvo ) [2] => Array ( [catid] => 16 [catparentid] => 11 [catname] => whostock ) )
--------------------------------------------------------------------------------
Array ( [0] => Array ( [catid] => 17 [catparentid] => 10 [catname] => mercedes ) [1] => Array ( [catparentid] => 12 [catid] => 14 [catname] => volvo ) [2] => Array ( [catid] => 16 [catparentid] => 11 [catname] => whostock ) )

The same thing is repeated even after multisorting..could you explain me clearly how or what way it is sorted here..please..

thanks
karthikanov24
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 11-09-09, 07:47 PM
Jcbones Jcbones is online now
Coding Addict
 
Join Date: Mar 2009
Location: North Carolina, USA
Posts: 278
Thanks: 3
Thanked 5 Times in 5 Posts
You are not using array_multisort() right.

What are you sorting for? How do you want it sorted?

You may need to use asort().

Links below:
PHP: asort - Manual
PHP: array_multisort - Manual
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Make Rewrite Modul Working in Windows, cause .htaccess ist not working specialex Web Servers 5 04-09-08 12:07 PM
Form with Photo Upload not working HELP ! mckenzie ASP 1 11-02-06 03:46 PM
ASP not working in IIS5 on WinXP Pro cistate ASP 5 06-18-04 03:31 PM
[SOLVED] isLeapYear not working? viper2843 Everything Java 2 05-17-04 07:11 PM


All times are GMT -5. The time now is 10:00 PM.
vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.