Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #9483
| From | Christoph Becker <cmbecker69@gmx.de> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: comma placement problem |
| Date | 2013-05-20 23:05 +0200 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <kne36t$ec0$1@speranza.aioe.org> (permalink) |
| References | <bgnwqrwpql3u$.1hv0a1p6pymz3.dlg@40tude.net> |
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.
I usually prefer to build lists, which are *separated* by the same
string, by building a stack (array) of the items and letting the stack
implode() afterwards:
$list = array('One');
$list[] = 'Two';
$list[] = 'Three';
echo implode(', ' $list);
In this particular case I would build up the JSON as nested PHP array,
and then stringify it with json_encode().
--
Christoph M. Becker
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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