php quotation mark conversion method: first create a PHP sample code file; then define a "convertQuotToChinese" method; then use strpos and substr and other functions to convert quotation marks; finally execute the file and output the conversion result. .
Recommended: "PHP Video Tutorial"
php Convert English quotation marks into Chinese quotation marks in pairs
$test_string = 'this is a "test as" string juventus vs "napoli" is b a bing match'; echo convertQuotToChinese($test_string); function convertQuotToChinese($string) { $flag = false; //false显示开始的中文引号,true时显示结束的中文引号 while(false !== ($i = strpos($string, '"'))) { $begin_string = substr($string, 0, $i); $end_string = substr($string, $i+1-strlen($string)); $quot = $flag ? '”' : '“'; $flag = !$flag; $string = $begin_string.$quot.$end_string; } return $string; }
The above is the detailed content of How to convert English quotation marks to Chinese quotation marks in php. For more information, please follow other related articles on the PHP Chinese website!