How to break line inside textarea

2

I need to bring the listing of people within a textarea or some similar alternative.

I'm bringing it this way:

<textarea rows="5" name="pergunta4">
<?php foreach($avaliadores as $avaliador):?>
<?php echo($avaliador['nome']);?>
<?php endforeach; ?>
</textarea>

But the names of the evaluators end up coming either side by side or random.

    
asked by anonymous 11.04.2018 / 21:13

1 answer

3

Use \n to break the line within <textarea> :

<textarea rows="5" name="pergunta4">
<?php 
    foreach ($avaliadores as $avaliador) {
        echo $avaliador["nome"]."\n";
    }
?>
</textarea>

Example:

<textarea rows="5" name="pergunta4">
<?php 
    $avaliadores = array();
    $avaliadores[] = array("Id"=>"1", "Nome"=>"Caique");
    $avaliadores[] = array("Id"=>"2", "Nome"=>"Suporte");

    foreach ($avaliadores as $avaliador) {
        echo $avaliador["Nome"]."\n";
    }
?>
</textarea>

Anotherexample:

<textarearows="5" name="pergunta4">
<?php 
    $avaliadores = array("Caique", "Suporte", "Renan", "RBZ");
    foreach ($avaliadores as $avaliador) {
        echo "$avaliador\n";
    }
?>
</textarea>

    
11.04.2018 / 21:25