PHP - eregi_replace() 函式



語法

string eregi_replace (string pattern, string replacement, string originalstring);

定義和用法

eregi_replace() 函式的功能與 ereg_replace() 完全相同,只是它在字串中搜索模式時不區分大小寫。

返回值

  • 替換髮生後,將返回修改後的字串。

  • 如果沒有找到匹配項,則字串將保持不變。

示例

以下是一段程式碼,複製並貼上這段程式碼到一個檔案中並驗證結果。

<?php
   $copy_date = "Copyright 2000";
   $copy_date = eregi_replace("([a-z]+)", "&Copy;", $copy_date);
   
   print $copy_date;
?>

這將產生以下結果:

Eregi Replace
php_regular_expression.htm
廣告