preq_replace automatically adds single quote in Thai language

60 views Asked by At

My intention is to breaks groups of 50 chars that do not contain spaces with a \n

My code is like this:

$string= preg_replace('/([^\s<>]{50})(?=[^\s])/u', "$1\n$2", '[ติดต่อนัดหมายชมโครงการหรือสอบถามข้อมูลเพิ่มเติมที่]');

And the result adds \n and additional ' in the new line:

[ติดต่อนัดหมายชมโครงการหรือสอบถามข้อมูลเพิ่มเติมที\n
่]

But with an arbitrary value:

$string= preg_replace('/([^\s<>]{50})(?=[^\s])/u', "$1\n$2", '[ติดต่อนัดหมายชมโครงการหรือสอบถามข้อมูลติดต่อนัดัด]');

The result shows without ':

[ติดต่อนัดหมายชมโครงการหรือสอบถามข้อมูลติดต่อนัดัด\n
]

Why does it add additional ' in the new line ? How can I avoid it ?

0

There are 0 answers