84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
就是前端输出一段诸如/:8-)之类的代码,然后在前端把字符转成相应的QQ表情,请问有大神知道怎么样可以实现吗?
既然是 代码 转 表情,那么肯定会有一个代码与表情(图片地址)的映射吧!
$array = array( '/:8-' => '<img src="/path/to/face-1.jpg" />', '/:9-' => '<img src="/path/to/face-2.jpg" />', '/:10-' => '<img src="/path/to/face-3.jpg" />', ); $comment = '你好啊 /:8-,你在哪里呢/:10-?'; echo strtr($comment, $array);
结果:
你好啊 <img src="/path/to/face-1.jpg" />,你在哪里呢 <img src="/path/to/face-3.jpg" />?
正则或者字符串替换替换成img图片地址。。。
function replace_em(str){
str = str.replace(/\</g,'<'); str = str.replace(/\>/g,'>'); str = str.replace(/\n/g,'<br/>'); str = str.replace(/\[em_([0-9]*)\]/g,'<img src="face/$1.gif" border="0" style="width:20px; height:20px;" />'); str = str.replace(/\[img_([\d\D]*)\]/g,'<img src="upload/$1" border="0" style="width:20px; height:20px;" /><a href="upload/$1" target="_blank"></a>'); return str;
}
既然是 代码 转 表情,那么肯定会有一个代码与表情(图片地址)的映射吧!
结果:
正则或者字符串替换替换成img图片地址。。。
function replace_em(str){
}