Re: Arrays and Alphabetical order

From: Date: Tue, 22 Jul 2003 17:09:22 +0000
Subject: Re: Arrays and Alphabetical order
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-156277@lists.php.net to get a copy of this message
/* UNTESTED - and prolly could be more efficient */ $c = $d = ''; natsort($info); foreach ( $info as $i ) { $d = substr($i, 0, 1); if ( $d != $c ) echo "\n"; echo $i; $c = $d; } On Tuesday 22 July 2003 09:40 am, Don Mc Nair wrote: > Hi folks > > I am trying to print out a table of elements in alphabetical order. I have > an SQL query which sorts out the data in order and am using 'while ($info > =(mysql_fetch_row...etc)) to read the data array. I need it to echo out a > table with all the A's first, then a blank line, then all the B's, a blank > line and so on. I could write 26 different queries, one for each letter of > the alphabet, but surely there is a tidier way. > > Any help is appreciated. > > Don > > > --- > Outgoing mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.502 / Virus Database: 300 - Release Date: 18/07/2003 -- "He who fights too long against dragons becomes a dragon himself; and if you gaze too long into the abyss, the abyss will gaze into you." -Nietzche

« previous php.general (#156277) next »