Solving several problems about substitution and smarty
1 About Replacements
for ($i =0; $i < $res _length; $i + +) {
$res 1 = $res [$i];
$res 1[' content ' = Preg_replace ("/($selkey)/is", "
\\0", $res 1[' content ']);
$res 1[' content ' = stristr ($res 1[' content '), $selkey);
$res 2[] = $res 1;
/*echo "
";
Print_r ($res 1);
echo "
";
Exit (); */
Problem: This function shows that the content is normal, the first time $selkey from the content to the last, but why the first $selkey is not decorated with preg_replace style? And when I swap the preg_replace function with the STRISTR function position, the result is correct again?
2 about the TRUNCATE function in Smarty
With truncate processing the above code out of the results, was preg_replace modified all the styles are gone, I tried to add a hyperlink, the result is not, remove this function, and normal again, this is how it happened? (Because Smarty's truncate is not good for Chinese support, I used to download the modified truncate from the Internet, will this be the reason?) And if so, what should be solved? )
------Solution--------------------
Str_ireplace () will be able to meet your requirements.