discuz中正则替换soso表情标标签
程序员文章站
2022-04-02 16:07:31
...
/** * 替换内容中SOSO表情标签 * @author tangw * @param type $message */function parse_soso_smiles($message) { $message = preg_replace("/\{\:soso_((e\d+)|(_\d+_\d))\:\}/ies", "rep_soso_smiles('\\1')", $message); return $message;}/** * 替换so
/** * 替换内容中SOSO表情标签 * @author tangw * @param type $message */ function parse_soso_smiles($message) { $message = preg_replace("/\{\:soso_((e\d+)|(_\d+_\d))\:\}/ies", "rep_soso_smiles('\\1')", $message); return $message; } /** * 替换soso表情标签为img * (正则替换表情方法:parse_soso_smiles) * @author tangw * @param type $smilieid 正则替换后数据 */ function rep_soso_smiles($smilieid) { $imgid = 'soso_' . $smilieid; $width = '24'; $height = "24"; if (strpos($smilieid, '_') === 0) { $realsmilieid = $smiliekey = substr($smilieid, 0, -2); $serverid = intval(substr($smilieid, -1)); $imgsrc = "http://piccache{$serverid}.soso.com/face/{$realsmilieid}"; $ar_img = getimagesize($imgsrc); if ($ar_img) { $width = $ar_img[0]; $height = $ar_img[1]; } } elseif (strpos($smilieid, 'e') === 0) { $imgsrc = "http://cache.soso.com/img/img/{$smilieid}.gif"; } return ""; }
上一篇: 8个必备的PHP功能实例代码
下一篇: php如何让浏览器显示错误