Asheeown Posted January 24, 2007 Share Posted January 24, 2007 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 commasFor example:The user can select from two sources: 500,501Checkboxes would be: Source[1] and Source[2], I have that part coverednow I want to build a variable with those Sources together separated by commasBut the number of sources can be different Link to comment https://forums.phpfreaks.com/topic/35587-building-an-array-with-commas-in-between-vars/ Share on other sites More sharing options...
The Little Guy Posted January 24, 2007 Share Posted January 24, 2007 The Form[code]<input type="checkbox" name="source[]" value="500"><br><input type="checkbox" name="source[]" value="501">[/code]The PHP[code]<?php$str = implode(", ", $_POST['soruce']);echo $str;?>[/code] Link to comment https://forums.phpfreaks.com/topic/35587-building-an-array-with-commas-in-between-vars/#findComment-168546 Share on other sites More sharing options...
snowrhythm Posted January 24, 2007 Share Posted January 24, 2007 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. Link to comment https://forums.phpfreaks.com/topic/35587-building-an-array-with-commas-in-between-vars/#findComment-168550 Share on other sites More sharing options...
Asheeown Posted January 24, 2007 Author Share Posted January 24, 2007 Thanks to the both of you, I really appreciate the help, works perfect! Link to comment https://forums.phpfreaks.com/topic/35587-building-an-array-with-commas-in-between-vars/#findComment-168551 Share on other sites More sharing options...
snowrhythm Posted January 24, 2007 Share Posted January 24, 2007 the little guy beat me...the story of my life. Link to comment https://forums.phpfreaks.com/topic/35587-building-an-array-with-commas-in-between-vars/#findComment-168552 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.