Page 1 of 1

A - Z

Posted: Sat Dec 03, 2005 8:40 pm
by $var
I have a list of bands that are both alpha and numerically titled. (ie: 63 Monroe, .50)

I am currently sorting them into a-z with this code

Code: Select all

if($_POST["bandletter"]=="")
		{
			$bandletteru="A";
			$bandletterl="a";
		}
		else
		{
			$bandletteru=strtoupper($_POST["bandletter"]);
			$bandletterl=strtolower($_POST["bandletter"]);
		}
and

Code: Select all

<?for($x=65; $x<91; $x++)
		{?>
		<a class="navhover" href="#" onClick="document.nav.bandletter.value='<?=chr($x);?>'; document.nav.submit();">&#<?=$x;?>; </a>
		<?}?>	
		<
But this doesn't display any names starting with a number or other character.
Can this be remedied to list all of them under say... a hash mark for 'misc'?

Re: A - Z

Posted: Sun Dec 04, 2005 5:32 am
by foobar
$var wrote: But this doesn't display any names starting with a number or other character.
Can this be remedied to list all of them under say... a hash mark for 'misc'?
Why not use natsort(). I'm not sure how it handles non-alphanumeric characters, but it'll almost certainly put them in some kind of order. Then just split up your array with a foreach loop into groups of the same starting character, unless it's a non-alphanumeric character, in which case you'd just leave all of them in the same group.