Eğer çözümün sadece ilgileniyorsanız, son satıra atlayın.
Here's what ended up happening. I had a div tag in html that contained certain information.
When a user hits a button, a JS code runs that converts that div to an input textbox, and sets the value of that textbox as the html of the original div - while replacing all occurrences of <br> with \n to create real line breaks.
The form then got submitted via ajax to the server.
When I tried to replace the line breaks in PHP, none of the above suggestions helped, for the simple reason that it wasn't (curiously enough) a "real" linebreak character. What got submitted to the server was the literal \n.
You'd think escaping the backslash in \n, as suggested by ghostdog74 would solve the problem but it did not. I tried escaping it several different ways but nothing seemed to help.
Ben bazı eski regex malzemeyi referans sona erdi ve bulundu:
Birçok tatlar da \ S. .. \ E kaçış dizisi destekler. \ Q ve \ E arasındaki tüm karakterler değişmez karakter olarak yorumlanır. Örneğin \ S * \ d + * \ e edebi metin maçları \d+. \ E regex sonunda ihmal edilebilir ... Bu sözdizimi JGsoft motoru tarafından desteklenir, Perl, PCRE ... [source]
Bunu takiben, burada benim sorunum çözüldü kod parçası:
$text = preg_replace('#[\Q\n\E]+#', "\n", $text);
Tüm yardımlarınız için herkese teşekkür! Tüm :) için 1