sorting an array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
php idiot
Forum Newbie
Posts: 3
Joined: Mon Sep 08, 2008 8:59 am

sorting an array

Post by php idiot »

I have an array with objects in it.
I need to sort this array by one of the fields inside the object. (field : price)
does anyone know how to do this?
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: sorting an array

Post by onion2k »

Use usort() with a custom function. Example 3 on the manual page is exactly what you're after - http://uk2.php.net/usort
Post Reply