Comma seperated implode & modifying returned string.


Posted on 16th Feb 2014 07:03 pm by admin

I have a PHP post form that posts up to 4 variables. I need whatever variables are passed to be combined into one comma seperated string (eg variable1,variable2,variable3,variable4). This i can do with the code below.

Code: [Select]$combo = array($one, $two, $three, $four);
$list = implode(",", $combo);
Did you know?Explore Trending and Topic pages for more stories like this.

my problem is that the form fields are optional by design so that the user doesn't always post all 4 variables. Sometimes they will post 1, sometimes they will post all 4. So if a user only selects two fields and submits the form i will end up with a string looking like:
variable1,variable2,,
when what i really want is (note the removal of the trailing commas at the end of the string):
variable1,variable2

Can anyone point me towards a possible solution for this?
No comments posted yet

Your Answer:

Login to answer
297 Like 14 Dislike
Previous forums Next forums
Other forums

If statement help please.
Hello on my site I have 2 content boxes. 1 is for the main content (which is the biggest one) and th

PHP Code / Script To check weather the given email exists in a domain
Hi,

I want to implement the following in my web page

in sign up we will ask to enter u

PHP search multiple input field box help
I am having a problem with my search script. At current it will simply search by a selected date whi

Business Health Check
Hello

I need to create an online business health check for a client it will be multiple choi

Customizing message/behavior
Hi,I'm using the ASP.NET membership/authorization controls in my application. Some parts of my appli

moving mouse to display image coordinates
I have an existing MFC application that shows an image in the main window.
I'd like to be able to

asking for direction
I have 2 tables in my data, which are "post" and "event"
I won't make a summa

TimeStamp Column Problem...
I'm mad at my self and thinking I'm a little retarded. It just be some one mistake I'm missing here.

Help please - How to validate from 2 possible answers
Hi

I hope somebody can help me with what will probably be really simple, I'm pulling my hair

Unique Visitor Tracking
Hello. Currently, I run a voting site where voters are tracked by their IP address and can only vote

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash