Replace preg_replace() to preg_replace_callback() [duplicate]

怎甘沉沦 提交于 2019-11-28 01:23:02

Read the documentation here, http://www.php.net/manual/en/function.preg-replace-callback.php

Here is an example of preg_replace_callback

$source = preg_replace_callback('/&#(\d+);/m', function($matches){
   return utf8_encode(chr($matches[1]));
}, $source);
$source = preg_replace_callback
(
    '/\&\#(\d+)\;/m',
    function($match){
        return utf8_encode(chr($match[1]));
    },
    $source
);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!