$data = $this->em->getRepository('App\\Entity\\Data')->findAll();
foreach ($data as $key => $value) {
$str1 = $value->getContent();
$str2 = "Line 1\nLine 2\rLine 3\r\nLine 4\n";
$order = array("\r\n", "\n", "\r");
$replace = '<br>';
$newstr1 = str_replace($order, $replace, $str1);
$newstr2 = str_replace($order, $replace, $str2);
}
Вывод $ newstr2:
"Line 1<br>Line 2<br>Line 3<br>Line 4<br>"
Вывод $ newstr1:
"Animals \n- 123 / N23\n- Monkeys together\n- 4 x 400ft. Farm rabits\n- 2 x 1000ft. Horses Cats\n- Group with all farm members\n- Flowers \n- Food\n- Love 400 -Random\r\n- 2-Countries\r\n- 1 x Hotel 4\"x4\"" \r\n- 1 x Shelter \r\n- Plate \r\n- Pillow \r\n- Cards"
Я не понимаю, почему \n
не заменяется в $ newstr2