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);

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

Sending an SMS Message with ASP.NET
Often times it may be a requirement for your web application to send an SMS message. Such examples w

Registration
ok so i have a site where people can register and login which works now thanks to someone on here th

Help a newbee save my job !
Hey guys i am dying here i am new to php and would like for someone to help me with this problem

add text and number image
hi guys ..

ok see i want the user to add their name and pick a number then click get it and i

Better Method of a Member Cloud
I assume most people know how tag clouds work, where the tags most used are bigger and the least use

distinct rows
Hi
version 10.2.0.3

I have a query output something like the following

ID

Thread in PHP
Thread in PHP
Some basic use and basic code for thread in php
This is my question?

help with calculations on a flat text file
hello,
I have this code below that is attached to a flat file like this:
Email:LastName:FirstN

While Problem
i am having a problem with a while statement here is the code
Code: [Select]<?php
sess

if php cookie set, show code...
Hi all.. I need to figure out this little snippet right quick.. seems like it should be easy enough

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