转换“;到';内部html


Convert " to ' inside html

我尝试过的代码:

$var = '<a href="hellow"> Test </a>'; // Convert " to '
echo preg_replace('/<([^<>]+)>/e', '"<" . str_replace(''"'', "''", "$1") . ">"', $var);
echo preg_replace_callback(
    '/<([^<>]+)>/',
    function($m) { return str_replace('"', "'", $m[0]); },
    $var);