Webmaster Forum Rules | Posting Guide | Contact Us | Testimonials | Contributing Geek Program | Advertise on Geek/Talk
Welcome to the GeekTalk Webmaster Discussion Forums from GeekVillage.com

Click Here To Register. It's Free!

Go Back   geek/talk: Signature-free discourse for serious web publishers > YOUR CREATION: Building & Maintaining A Web Site > Web Development - Programming / Coding
User Name
Password
Register FAQ Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 05-29-2002, 05:43 AM   #1
AhmedF
Registered User
 
AhmedF's Avatar
 
Join Date: Mar 2001
Location: Toronto
Posts: 671
Question Sorting Multidimensional Arrays in PHP

I have a question that is giving me a headache

Lets say we have an array, $a, that is multi dimensioned

For example:

$a[0]['a'] = 5;
$a[0]['clicks'] = 15;
$a[0]['time'] = 5:30;

$a[1]['a'] = 1;
$a[1]['clicks'] = 10;
$a[1]['time'] = 5:30;

$a[2]['a'] = 7;
$a[2]['clicks'] = 11;
$a[2]['time'] = 7:30;

Is it possible to sort these by 'clicks' while the actual rows stay intact?

Basically, after sorted, it would be like so:

$a[0]['a'] = 1;
$a[0]['clicks'] = 10;
$a[0]['time'] = 5:30;

$a[1]['a'] = 7;
$a[1]['clicks'] = 11;
$a[1]['time'] = 7:30;

$a[2]['a'] = 2;
$a[2]['clicks'] = 15;
$a[2]['time'] = 5:30;


I have been fooling around with array_multisort, but it cant seem to be able to figure out how to use it in such a sitatuion.

Any Ideas? [I could do it in a very cumbersome method, but I was just wondering if you can do it using PHP's in built methods]
AhmedF is offline   Reply With Quote
Old 06-01-2002, 11:29 AM   #2
netrift
Registered User
 
Join Date: May 2002
Posts: 8
Default

Take a look at uasort()

http://www.php.net/manual/en/function.uasort.php

cheers
netrift is offline   Reply With Quote
Reply

Bookmarks

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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl vs PHP? ccole Web Design and Webmaster Issues 4 09-14-2016 12:54 AM
Dumb Perl + PHP questions WildComputer Web Design and Webmaster Issues 6 01-06-2001 08:49 PM
Coding a PHP fileboard truelight Web Design and Webmaster Issues 1 12-15-2000 11:05 AM
PHP question Tyme Web Design and Webmaster Issues 4 08-04-2000 03:39 PM
PHP a good choice for me? Kurbin Web Design and Webmaster Issues 4 07-16-2000 02:40 AM

Please support our advertisers. They ensure our survival.

All times are GMT -5. The time now is 01:24 PM.


GeekVillage.com is copyright © 1998-2015 Curiosity Cave - Science gifts for clever kids. All rights reserved.
Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.