Solving several minor problems about substitution and smarty

Source: Internet
Author: User
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? )

Str_ireplace () will be able to meet your requirements.
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.