PHP PHP 文字列を置換する

-


Topページ  >  お勉強  >  PHP  >  文字列を置換する 

文字列を置換する

PHPで、文字列を置換する方法です。





1. str_replace関数の使用例です。

// 置換対象文字列
$targetText = "AABBAA";

// "A" という文字列を "×" に置換する
$replaceText = str_replace("A", "×", $targetText);




afterString = str_replace( targetString , replaceString , beforeString )


afterString 置換された結果の文字列
targetString 置換対象の文字列
replaceString 置換する文字列
beforeString 元の文字列



↓インラインフレーム内でサンプルが動作しています。






Topページ  >  お勉強  >  PHP  >  文字列を置換する 






-