Solve several minor issues about replacement and smarty

Source: Internet
Author: User
Solve several questions about replace and smarty 1 about replace for ($ I = 0; $ I & lt; $ res_length; $ I ++) {$ res1 = $ res [$ I]; $ res1 ['content'] = preg_replace (& quot;/($ selkey)/is & quot;, & quot; & lt; fontcolo solves several questions about replacement and smarty
1. about replacement
For ($ I = 0; $ I <$ res_length; $ I ++ ){
$ Res1 = $ res [$ I];
$ Res1 ['content'] = preg_replace ("/($ selkey)/is "," \ 0", $ Res1 ['content']);
$ Res1 ['content'] = stristr ($ res1 ['content'], $ selkey );
$ Res2 [] = $ res1;
/* Echo"
";
Print_r ($ res1 );
Echo"
";
Exit ();*/

Q: the content displayed in this function is normal. it is the first time that $ selkey appears from the content to the final content. why is the first $ selkey not modified by the preg_replace style? After I swap the positions of the preg_replace and stristr functions, the result is correct?

2. about the truncate function in smarty
Use truncate to process the results of the above code. all the styles modified by preg_replace are gone. I tried to add a hyperlink and the results won't work either. after removing this function, it's normal again. what's going on? (Because the truncate of smarty has poor support for Chinese characters, is it because I downloaded the modified truncate from the internet? If so, how can this problem be solved ?)

------ Solution --------------------
Str_ireplace () can meet your requirements.

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: info-contact@alibabacloud.com 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.