By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,216 Members | 1,001 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,216 IT Pros & Developers. It's quick & easy.

implode or what?

P: n/a
I'm not quite sure which function to use when I want to add a comma to
the end of every line and a semi colon to the last one. Because it
generates everything on the fly I can't count the rows from a db.
Here's what I want to do:

red, <--Comma
green, <--Comma
blue, <--Comma
orange; <--Last one so semi colon

Any help is greatly appreciated
Oct 4 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Message-ID:
<c7**********************************@b38g2000prf. googlegroups.comfrom
Igoogler contained the following:
>I'm not quite sure which function to use when I want to add a comma to
the end of every line and a semi colon to the last one. Because it
generates everything on the fly I can't count the rows from a db.
Here's what I want to do:

red, <--Comma
green, <--Comma
blue, <--Comma
orange; <--Last one so semi colon

Any help is greatly appreciated
assuming the above are in an array called $colours

echo implode(",",$colours).";";

But this is so basic, couldn't you have got the answer by looking at the
manual and trying a few examples?
--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011
http://slipperyhill.co.uk - http://4theweb.co.uk
Oct 4 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.