2017-03-01 80 views
-2

我如何轉換這個字符串在PHP例如將英文雙引號法國報價

$str = 'Hello world "some text"' 

'Hello world «some text»' 
+0

你嘗試過什麼到目前爲止?我們在這裏幫助解決精確的問題,而不是免費的代碼。 – NaeiKinDus

+3

'str_replace()函數'或'的preg_replace()'是一個開始...給它一個鏡頭,然後再回來,當你遇到問題 – WillardSolutions

+0

退房http://php.net/manual/en/function.str- replace.php來實現這一點。 –

回答

0

這樣的:

<?php 
    $str = 'Hello world "some text"'; 
    $regex = '/"(.*?)"/'; 
    $subst = '«$1»'; 
    $result = preg_replace($regex, $subst, $str); 
    echo $result; 
?> 
+0

了' u'修飾符可能對法語文本有意義,並且_please_將刪除關閉的php標記... – arkascha