ForEach Range Problems
| From: | Miller, Terion | Date: | Fri, 31 Jul 2009 16:53:14 +0000 |
| Subject: | ForEach Range Problems | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-296127@lists.php.net to get a copy of this message | ||
I have this script that works, just a couple tweeks needed...
1. I don't want it to default to A being selected
2. I need the number range part to only display one # sign not 10 of them,
somehow I have to have it pull any record that does not start with alpha
<?php
$letter =
isset($_GET['letter']) ? $_GET['letter'] :"A";
echo '<div
align="center"><b>';
foreach(range('A','Z') as $c){
($letter == $c)
?
printf('%s ',$c)
: printf('<a
href="browse.php?letter=%s">%s</a> ',$c,$c);
}
echo '<br>';
//Other
foreach(range('0','9') as $n){
($letter == $n)
?
printf('%s ',$n)
: printf('<a
href="?letter=%s">#</a> ',$n,$n);
}
echo
"</b><br></div><p>";
?>