Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/235.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP-preg_replace更改表情符号图像的表情符号代码_Php - Fatal编程技术网

PHP-preg_replace更改表情符号图像的表情符号代码

PHP-preg_replace更改表情符号图像的表情符号代码,php,Php,我想将所有表情符号代码从我的字符串更改为表情符号图像。 这是我的数组,包含代码和URL: $smilies = array( array('http://page.com/facebook-smiley-face-for-comments.png', ':)'), array('http://page.com/big-smile-emoticon-for-facebook.png', ':D'), array('http://page.com/facebook-frown

我想将所有表情符号代码从我的字符串更改为表情符号图像。 这是我的数组,包含代码和URL:

$smilies = array(
    array('http://page.com/facebook-smiley-face-for-comments.png', ':)'),
    array('http://page.com/big-smile-emoticon-for-facebook.png', ':D'),
    array('http://page.com/facebook-frown-emoticon.png', ':('),
    ...
);
下面是更改图像代码的脚本:

foreach($smilies as $emoticon)
{
    $quoted_emoticon = preg_quote($emoticon[1],"#");
    $match = '#(?!<\w)(' . $quoted_emoticon .')(?!\w)#';
    $message = preg_replace($match,'<img src="'.$emoticon[0].'">',$message);
}
foreach($smilies as$emoticon)
{
$quoted_emoticon=preg_quote($emoticon[1],“#”);

$match='#(?!更改您的正则表达式模式,仅当某个表情符号代码的前面或后面没有非空格字符时才允许匹配:

...
$match = '#(?<!\S)(' . $quoted_emoticon .')(?!\S)#iu';
...
。。。
$match='#(?