I am trying to make a emoji system using php for my website comment earea. I have created the table for emoji list. Like this:
+----------+------------+-------------+
| emoji_id | emoji_key | emoji_img |
+----------+------------+-------------+
| 1 | :smile: | smile.png |
+----------+------------+-------------+
| 2 | :heart: | heart.png |
+----------+------------+-------------+
So for example user posted a comment like this:
Hi this is a first comment i :heart:
this comment :smile:
.
I want to detect the text for emoji. If emoji_key is exist in the comment then replace the :heart: to heart.png .
<img src="emoji/<?php echo $emoji_img;?>" />
is there anyway to do this ?
For example:
$userComment = 'Hi this is a first comment i :heart: this comment :smile: .';
Pring should like this:
Hi this is my first comment <img src="emoji/heart.png"> this comment <img src="emoji/smile.png">
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…