Timothy Boyden wrote:
> Hi All,
>  
> I have a multi-dimensional array such as:
>  
> $franchises['SCID1'] = SCNYC
> $franchises['SCID1']['BusinessName'] = SuperCoups of NY City
> $franchises['SCID1']['DistanceFromCustomer'] = 20
> $franchises['SCID2'] = SCBUFF
> $franchises['SCID2']['BusinessName'] = SuperCoups of Buffalo
> $franchises['SCID2']['DistanceFromCustomer'] = 10
>  
> How can I sort this array so the businesses are sorted by the
> DistanceFromCustomer key?

Firstly, your array above looks somewhat suspect, you might want to use
actual code for your example.

That said, try the following:

$franchises = array();
$franchises['SCID1'] = array();
$franchises['SCID1']['BusinessName'] = 'SuperCoups of NY City';
$franchises['SCID1']['DistanceFromCustomer'] = 20;
$franchises['SCID2'] = array();
$franchises['SCID2']['BusinessName'] = 'SuperCoups of Buffalo';
$franchises['SCID2']['DistanceFromCustomer'] = 10;

uasort($franchises,create_function('$a,$b','return
strnatcmp($a["DistanceFromCustomer"],$b["DistanceFromCustomer"]);'));

Dan
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php

Reply via email to