Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #9479

Re: comma placement problem

Path csiph.com!usenet.pasdenom.info!news.etla.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!eternal-september.org!feeder.eternal-september.org!mx05.eternal-september.org!.POSTED!not-for-mail
From "Peter H. Coffin" <hellsop@ninehells.com>
Newsgroups comp.lang.php
Subject Re: comma placement problem
Date Mon, 20 May 2013 14:48:27 -0500
Organization A noiseless patient Spider
Lines 32
Message-ID <slrnkpkvgb.msg.hellsop@nibelheim.ninehells.com> (permalink)
References <bgnwqrwpql3u$.1hv0a1p6pymz3.dlg@40tude.net>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
Injection-Info mx05.eternal-september.org; posting-host="4163d0103afdb3d32fe6c98974b1e330"; logging-data="16745"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19+NFoaOET4Jd3GPGUopt/g"
User-Agent slrn/0.9.9p1 (OpenBSD)
Cancel-Lock sha1:GWyHCUzHY1O7HL0JrNxMnT/FV3c=
Xref csiph.com comp.lang.php:9479

Show key headers only | View raw


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

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

comma placement problem richard <noreply@example.com> - 2013-05-20 14:32 -0400
  Re: comma placement problem "Peter H. Coffin" <hellsop@ninehells.com> - 2013-05-20 14:48 -0500
  Re: comma placement problem Salvatore <sal@yojimbo.hack.invalid> - 2013-05-20 19:57 +0000
  Re: comma placement problem Luuk <luuk@invalid.lan> - 2013-05-20 22:00 +0200
    Re: comma placement problem richard <noreply@example.com> - 2013-05-20 16:40 -0400
  Re: comma placement problem Christoph Becker <cmbecker69@gmx.de> - 2013-05-20 23:05 +0200
  Re: comma placement problem Paul Herber <paul@pherber.com> - 2013-05-21 09:51 +0100

csiph-web