FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » comma placement problem
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: comma placement problem [message #181531 is a reply to message #181530] Mon, 20 May 2013 19:48 Go to previous messageGo to previous message
Peter H. Coffin is currently offline  Peter H. Coffin
Messages: 245
Registered: September 2010
Karma:
Senior Member
On Mon, 20 May 2013 14:32:02 -0400, richard wrote:
> This does exactly what I want except that when 1969 is reached, the commas
> don't get placed where I want them.
> I need the commas on every line except for the last line.
> which is why I put the conditional just before the \n.
>
>
>
>
>
> $year=1960;
> $number=1;
> $number=(int)$number;
> $year=(int)$year;
>
>
> while ($year<=1969):
>
.....
> if ($year<1969 and $number<=10){echo ",";}
> echo "\n";
> $number++;
> endwhile;

Off-by-one problems usually stem from mismatching "<" and "<=".
Experiment there.

--
7. When I've captured my adversary and he says, "Look, before you kill
me, will you at least tell me what this is all about?" I'll say,
"No." and shoot him. On second thought I'll shoot him then say "No."
--Peter Anspach's list of things to do as an Evil Overlord
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Immediate Position:::Business Analyst With BI EXP::::At Houston, TX
Next Topic: Problem with quotes in javascript output
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 09:43:12 GMT 2024

Total time taken to generate the page: 0.07985 seconds