I have a textarea in a html form where I put:
line1
line2
line3
Then I press button and send the text via jquery ajax to a php script that handles the ajax request and needs to enter each line to db table as a separate row.
Currently, I send the string as
encodeURIComponent($('#multiline_text').val()) in data: variable in jquery
then I'm trying to break the text into array using explode('\n', $multiline_text)
in the php file and then enter each row to db table using foreach.
But I'm getting only one array element and that element is being entered as one row only into the db table and the row has value: "line1 line2 line3" without quotes, instead of having 3 separate rows in the table with values:
line1
line2
line3
What should I do?