Re: ForEach Range Problems
| From: | Shawn McKenzie | Date: | Fri, 31 Jul 2009 18:14:48 +0000 |
| Subject: | Re: ForEach Range Problems | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-296134@lists.php.net to get a copy of this message | ||
Miller, Terion wrote:
>
>
> On 7/31/09 12:43 PM, "Bastien Koert" <phpster@gmail.com> wrote:
>
> On Fri, Jul 31, 2009 at 1:40 PM, Miller,
> Terion<tmiller@springfi.gannett.com> wrote:
>>
>>
>> On 7/31/09 12:27 PM, "Bastien Koert" <phpster@gmail.com> wrote:
>>
>> $letter = isset($_GET['letter']) ? $_GET['letter'] :"";
>>
>> 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
>> $bNumberShown = false;
>> foreach(range('0','9') as $n){
>> if($letter == $n) {
>> printf('%s ',$n)
>> }else{
>> if ($bNumberShown){
>> printf('<a
>> href="?letter=%s">%s</a> ',$n,$n);
>> }else{
>> printf('<a
>> href="?letter=%s">#%s</a> ',$n,$n);
>> $bNumberShown = true;
>> }
>> }
>>
>> echo "</b><br></div><p>";
>>
>> Looks like it would work but I keep getting syntax error unexpected { at the first
>> }else{
>> I have tried to move the brackets around but it just moves the error....
>>
>
> My bad, missed a closing curly brace on the foreach loop
>
> <?php
> $letter = isset($_GET['letter']) ? $_GET['letter'] :"";
>
> 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
> $bNumberShown = false;
> foreach(range('0','9') as $n){
> if($letter == $n) {
> printf('%s ',$n)
> }else{
> if ($bNumberShown){
> printf('<a href="?letter=%s">%s</a> ',$n,$n);
> }else{
> printf('<a href="?letter=%s">#%s</a> ',$n,$n);
> $bNumberShown = true;
> }
> }
> }
> echo "</b><br></div><p>";
>
> ?>
>
> --
>
> Bastien
>
> Cat, the other other white meat
>
> Argh still nothing just the blank page of death...
Maybe you need a ; after printf('%s ',$n).
Also, maybe you need an editor with a syntax highlighter? You and PJ
should get together and decide on one.
--
Thanks!
-Shawn
http://www.spidean.com