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 ?