preg_replace
字符串比對解析並取代。
語法:mixedpreg_replace(mixedpattern,mixedreplacement,mixedsubject);
返回值:混合類型資料
函數種類:資料處理
內容說明
本函數以pattern的規則來解析比對字符串subject,欲取而代之的字符串爲參數replacement。返回值爲混合類型資料,爲取代後的字符串結果。
使用範例
下例返回值爲$startDate=6/19/1969
複製代碼 代碼如下:
<?php
$patterns=array("/(19|20d{2})-(d{1,2})-(d{1,2})/","/^s*{(w+)}s*=/");
$replace=array("3/4/1","$1=");
printpreg_replace($patterns,$replace,"{startDate}=1969-6-19");
?>