search
Homephp教程php手册discuz中正则替换soso表情标标签

discuz中正则替换soso表情标标签

Jun 06, 2016 pm 08:08 PM
discuzcontentreplaceLabelregularexpression

/** * 替换内容中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 "<img src="/static/imghwm/default1.png" data-src="http://www.tangwen.org/archives/\" class="lazy" smilieid='\"{$imgid}\"'   style="max-width:90%"width:"' . border='\"0\"' alt='\"\"'>";
}

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.