2016-11-03 7 views
0

私は例えば、この文字列を持っている一つのコマンド これは $がつながる結果であると、各sympolにスペースを追加する方法 複数のシンボルにスペースを追加する

$string="[email protected]|par/agra\phs"; // @-|/\ 
:「置く戻っ@ - との間に|パー/アグラ\ PHS私は、このソリューションを使用しているが、私はより良い存在しているかどうかを知りたいと思い、この

<?php 
$string="[email protected]|par/agra\phs"; // @-|/\ 
$str=preg_replace("/[@]/", " @ ", $string); 
    $str=preg_replace("/[-]/", " - ", $str); 
    $str=preg_replace("/[|]/", " | ", $str); 
    $str=preg_replace("/[\/]/", "/", $str); 

感謝。

答えて

0
<?php 
$string="[email protected]|par/agra\phs"; // @-|/\ 
$str=preg_replace("/([@|\-|\||\\\\|\/])/", " $1 ", $string); 
echo $str; 

demoをご覧ください。

+0

は、このソリューションのためにありがとうございました – logitech2004

関連する問題