Reply to Re: Group an array

Your name:

Reply:


Posted by strawberry on 01/30/07 12:31

On 30 Jan, 10:56, Curtis <dyers...@verizon.net> wrote:
> On Mon, 29 Jan 2007 06:07:48 -0800, Erwin Moller
>
>
>
> <since_humans_read_this_I_am_spammed_too_m...@spamyourself.com> wrote:
> > craig.keight...@gmail.com wrote:
>
> >> i have the following array:
>
> >> Array
> >> (
> >> [0] => Array
> >> (
> >> [0] => Leamore Windows Ltd
> >> [1] => 553398833511417
> >> [2] => 20
> >> )
>
> >> [1] => Array
> >> (
> >> [0] => HRPC
> >> [1] => 920589205210538
> >> [2] => 1
> >> )
>
> >> [2] => Array
> >> (
> >> [0] => Leamore Windows Ltd
> >> [1] => 553398833511417
> >> [2] => 2
> >> )
>
> >> )
>
> >> is it possible to group the items in the array and order by name to
> >> output the following:
>
> >> Array
> >> (
> >> [0] => Array
> >> (
> >> [0] => HRPC
> >> [1] => 920589205210538
>
> >> [2] => 1
> >> )
>
> >> [1] => Array
> >> (
> >> [0] => Leamore Windows Ltd
>
> >> [1] => 553398833511417
> >> [2] => 22
> >> )
>
> >> )
>
> > Hi,
>
> > Have a look at usort()
> >http://nl2.php.net/manual/en/function.usort.php
>
> > With usort you can define your own sortingrules.
>
> > Regards,
> > Erwin MollerThe OP may want array_unique. After which, they could sort.
>
> @the OP: you'll probably have to write a recursive function using
> array_unique to handle multi-dimensional arrays.
>
> --
> Curtis

The tips provided look very useful - but i wonder where the data's
actually coming from? If it's from a sql database then it would far
simpler to do the manipulations there.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация