Convert the smilies expression in the forum post content to a normal image display

Source: Internet
Author: User
: This article mainly describes how to convert the smilies expression in the forum post to a normal image display. For more information about PHP tutorials, see. Not long ago, when I called the forum Reply content, I encountered an smilies emoticons Image: {: 4_267 :}. the solution is described below.

On the server side, use regular expressions to format the smilies diagram in the post content of the Forum (take Discuz7.2 as an example) into the image label format, and then append the attributes to facilitate JS processing in the view.
Of course, you can optimize the image by yourself. this is initially intended to achieve normal image display.

Foreach ($ postList as $ key => $ val) {$ message = preg_replace ('/.*? <\/I> (\ s | (
) */Is ', '', $ val ['message']); // The Post is Last edited by XX at, January 6 //... omit emoticon Image $ message = preg_replace ('/\{\: (\ d) _ (\ d +) \:\}/im' in other code // forum Reply content ', '', $ message); $ postList [$ key] ['message'] = trim ($ message );}

Next, introduce the smilies_var.js file in the view.

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.