PHP Get data from input text separated by commas?

Jacob

New member
Hello. I have an html form with input (text). The user should insert data into this form and separate it by commas. Each value should be inserted into the database separately.
For example input: apple, window, door, pencil
PHP insert into mysql Apple as separate field, window as separate fields and so on...
I tried some manipulation with arrays but no luck...
 
I'm surprised nobody answered this.

Anyhow I hope this helps.

$input = "word1, word2, word3";
$inputarray = preg_split("/[\s]*[,][\s]*/", $input);

the input data would be $input, and $inputarray is now an array with the values from $input.
note: the input data must be separated by commas, and any number of spaces
 
Back
Top