0
我試圖取代這個:替換 'E' 修飾符preg_replace_callback
$source = preg_replace('/&#(\d+);/me', "utf8_encode(chr(\\1))", $source);
與preg_replace_callback
和匿名函數。
什麼是正確的方法來做到這一點?
我試圖取代這個:替換 'E' 修飾符preg_replace_callback
$source = preg_replace('/&#(\d+);/me', "utf8_encode(chr(\\1))", $source);
與preg_replace_callback
和匿名函數。
什麼是正確的方法來做到這一點?
嘗試以下操作:
preg_replace_callback(
'/&#(\d+);/m',
function ($matches) {
return utf8_encode(chr($matches[1]));
},
$source
);
你說得對 - 我愛短路,壽 – 2014-09-24 14:23:40
千恩萬謝@Lorenzo馬爾 – Sight 2014-09-25 07:23:28
不客氣@Sight,如果你認爲這是正確的答案,不要忘記將其標記爲正確答案:) – 2014-09-25 08:04:44