: 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.