0
Opa,
I need to capture the text of the textarea, separate it by lines and then explode and separate it by commas.
$lines = explode("\n", $respostas);
$i = 0;
if ( !empty($lines) )
{
foreach ($lines as $line)
{
$i++;
//Adiciona Respostas
foreach($respostas as $key)
{
$sql = mysqli_query($conn, "INSERT INTO respostas
VALUES (
NULL, $i, '$key'
)");
}
//Adiciona Respostas
}
}
Where in mysql Insert, I need to save the content ($key) to the line ($i), but, is duplicating the Inserts according to the number of lines.
Example of the textarea:
teste, teste1, teste2
teste3, teste4
What’s in the $answers?
– Sr. André Baill
Contents of the textarea:

teste, teste1, teste2
teste3, teste4

Words must be separated by comma and line– sNniffer
Got it, it comes this way then
– Sr. André Baill
In the @Andrébaill case, here does not display formatting, I added the textarea’s sample content to the question
– sNniffer
tell me one thing, will all be separated by comma already? and another thing... the goal is to insert these records into the database?
– Sr. André Baill
Yes, the user will already enter the words separating them with the comma, including the separation between lines and will be for registration in the bank
– sNniffer
Let’s go continue this discussion in chat.
– Sr. André Baill