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

j1inmis Ouput layout changes
Hi,

Can anybody tell how can j1inmis output layout can be changed so that vendor names ge

PHP Array quick help
I need

$_SESSION{'username'} to be like this:


if $_SESSION['username'] = "gay

Custom list order
Hi there,

I have checked this tutorial and it's great till the point where I want to display

php or sql?
Sorry not sure if this is a sql problem or php the following code is supposed to delete data from th

Calling strings from other php class
I have test1.php{
$string1;
$string2;
....
... //10 strings in this class <

Career Change into SAP
Hai
I am sajesh ,did my diploma in Mechatronics i have a 4 years of experience in

Fatal error: Call to a member function fetchrow() on a non-object in C:xamppht
okay i have this query and everytime i add `item_id`=? to it... it gives me the error in the title..

filesize() returns 0
I have a socket program that runs in an infinite loop, listening for connections, in this socket I h

ctype() validation - allowing illegal characters
Hello,
I use ctype() to filter and validate a user form. However, I am trying to allow certain c

Sales orders ans reservations not taken into account on MPS / MRP
Hello,

I am implementing the MPS / MRP and I have the following problem:

I ha

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