PHP_EOL or \r\n

5 posts by 2 authors in: Forums > CMS Builder
Last Post: February 13, 2018   (RSS)

By Djulia - February 2, 2018

Hi,

Did you test with nl2br?

$orderNotes = nl2br($orderRecord['notes']);

http://php.net/manual/en/function.nl2br.php

Thanks,

Djulia

By ht1080z - February 3, 2018

Hi Djulia,

Thanks for your suggestion! Yes, I tried it but with no luck, only the below code worked in my case:

$orderNotes = str_ireplace(array("\r\n",'\r\n'),'<br />', $orderRecord['notes']);

Any hint how can I remove the newline \r\n that in the $POST from textarea (or change to <br/>) before inserting to MySQL?

Dear iTools team,

I didn't getting notification emails from the forum anymore. How can I opt-in again?

Karls

By Djulia - February 4, 2018

Hi

Can you test this (in my_form.php)?

<form method="post" action="?">  
<textarea name="comment"><?php echo htmlspecialchars(@$_REQUEST["comment"]); ?></textarea><br />
<input type="submit" name="submit" value="Submit">
</form>

<?php
echo nl2br2(@$_REQUEST["comment"]);

function nl2br2($string) {
    $string = str_replace(array("\r\n", "\r", "\n"), "<br />", $string);
    return $string;
}
?>

Otherwise, can you give an example of text?

Thanks,

Djulia

Thank you Djulia for your tips and support on this, sorry for not getting back to you sooner (still not getting forum email notifications).

My problem is when I try to output from MySQL cmsb textbox field where previously I stored from textarea with \r\n

Example (in Greek): Θέλω για ύφασμα το / 644c, (πουά μπλε)\r\nΌπως λέω σε όλες τις εκτυπωσεις

In my case the str_ireplace worked like I posted before.

Thank you again,
Karls