PHP - 字串替換函式 (Str Replace)



語法

mixed str_replace ( mixed $search , mixed $replace , mixed $subject [, int &$count ] )

定義和用法

用於將一個字串替換為另一個字串。

返回值

返回帶有替換值的字串或陣列。

引數

序號 引數及描述
1

find

指定要查詢的字串。

2

replace

指定用於替換 find 中的值。

3

string

指定要搜尋的字串。

4

count

用於計算被替換變數的數量。

示例

嘗試以下示例

<?php
   echo str_replace("park","point","tutorials park");
?>

這將產生以下結果:

tutorials point
php_function_reference.htm
廣告