There is a variable $sms_text .
Output var_dump($sms_text); :

 string(358) "Не работают: №*****, ДО наименование – с 00.00.2016 г., (СОБ, ОСТиТ, Касса, Прочее); №*****, ДО наименование – с 00.00.2016 г., (СОБ, ОСТиТ, Касса, Прочее); №*****, ДО наименование – с 00.00.2016 г., (СОБ, ОСТиТ, Касса, Прочее);" 

Tell me how to replace all line breaks with \n , since Is this text not correctly recognized by the parser?

UPD:
Those. it is necessary that in this variable instead of hyphen there was exactly the \ n symbol, for example:

 "Не работают:\n№*****, ДО наименование – с 00.00.2016 г., (СОБ, ОСТиТ, Касса, Прочее);\n№*****, ДО наименование – с 00.00.2016 г., (СОБ, ОСТиТ, Касса, Прочее);\n№*****, ДО наименование – с 00.00.2016 г., (СОБ, ОСТиТ, Касса, Прочее);" 
  • one
    $sms_text = str_replace("\r\n", "\n", $sms_text); - mnv
  • @mnv, maybe I didn’t write correctly, but it’s necessary that in this variable, instead of hyphenation, there was the \ n character, for example: "Не работают:\n№*****, ДО наименование – с 00.00.2016 г., (СОБ, ОСТиТ, Касса, Прочее);\n№*****, ДО наименование – с 00.00.2016 г., (СОБ, ОСТиТ, Касса, Прочее);\n№*****, ДО наименование – с 00.00.2016 г., (СОБ, ОСТиТ, Касса, Прочее);" After processing the function that you brought, everything remains as well - S.Ivanov
  • Then $sms_text = str_replace("\n", "\\n", $sms_text); - mnv

1 answer 1

Just replace the line break with the desired characters:

 $sms_text = str_replace("\r", "", str_replace("\n", "\\n", $sms_text)); 
  • @mvn, did this: $sms_text = str_replace("\n", "\\n\\r", $sms_text); . The line still remained with hyphenation, + characters were inserted there: "Не работают:<br> \n\r№*****, ДО наименование – с 00.00.2016 г., (СОБ, ОСТиТ, Касса, Прочее);<br> \n\r№*****, ДО наименование – с 00.00.2016 г., (СОБ, ОСТиТ, Касса, Прочее);<br> \n\r№*****, ДО наименование – с 00.00.2016 г., (СОБ, ОСТиТ, Касса, Прочее);" . Where <br> remained a transfer (I don’t know how to add a line break in the comments) - S.Ivanov
  • Then remove \r from the string: $sms_text = str_replace("\r", "", str_replace("\n", "\\n", $sms_text)); - mnv