I have a textarea where I can enter as many items as I want separated by a line break.
Then, in the php file I have this to get the values:
$colors = $_POST["colors"];
foreach ( preg_split ('/[\s*,\s*]*,+[\s*,\s*]*/', $colors) as $value)
{
echo $value.'<br>';
}
The items are passed correctly as with that code I can see all the items but in one line. I tried to store that in the database and it does, but only in one row.
For example, if I enter in the textarea this:
Red
Black
Dark Black
Blue
It prints like this:
Red Black Dark Black Blue
That is, it removes all the spaces at the beginning and at the end, but not the ones in the middle (which is exactly what I want).
My problem is in the way I deal with the array. I would like to print an element per line and therefore being able to store in the database one color per row.
Can anybody please help?
Thanks a lot!