Hello,
I believe/hope there is a simple fix. The preg_replace() is replacing all between and correctly. But the string “” is missing from the end area after calling preg_replace(). In other words, after preg_replace(), the portion located outside of and after and search/replace delimeters is also gone, unintentionally.
How do I preserve and display and future codings of this form in the final $str1 echo? Below is my code, actual output and desired output.
Thanks,
Code:
<?php $str1='START TEXT END TEXT'; $pattern = '#(.+?)#s'; $str1 = preg_replace($pattern, htmlentities(' ') ,$str1); echo $str1; ?>============================================
Actual Output:
START TEXT
============================================
Desired Output:
START TEXT
END TEXT