Adding newline to PHP string

JJonas

I'm trying to add new line at the end of string, so I could better see <option> in new lines, hovewer I get string with "\r\n" as text instead of new lines. What is wrong with code ?

foreach ($xml['ROW'] as $ar) {
   $tekstas = $ar['zz'] . ' (' . $ar['xx'] . ')';
   $insert .= '<option value="' . $ar['Adresas'] . '">' . $tekstas .'</option> "\r\n"' ;
}
echo nl2br(htmlentities($insert));
Twisted1919

Almost there, look at the right way to concatenate the new line to the rest of the string you generate.

foreach ($xml['ROW'] as $ar) {
 $tekstas = $ar['zz'] . ' (' . $ar['xx'] . ')';
 $insert .= '<option value="' . $ar['Adresas'] . '">' . $tekstas   .'</option> ' . PHP_EOL ;
}
echo nl2br(htmlentities($insert));

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related