Jump to content

Building an array with commas in between vars


Asheeown

Recommended Posts

I have a form that allows a user to select certain Ids from a table and I want to take the sources and build one variable with all the information separated by commas

For example:
The user can select from two sources: 500,501

Checkboxes would be: Source[1] and Source[2], I have that part covered

now I want to build a variable with those Sources together separated by commas

But the number of sources can be different


hey!  do it like this...

[code=php:0]
$source1 = $_GET['source1'];
$source2 = $_GET['source2'];

$sourceArray = array($source1,  $source2);

$myCommaSeperatedVariable = implode(",", $sourceArray);
[/code]

and then $myCommaSeperatedVariable will be what you want, if I understand the question right.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.