記錄範例:PHP preg_replace 函數
<?php
echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'; //輸出網頁編碼為 utf-8
$subject="Hi, My name is John. I love travel.";
$pattern='John';
$replacement='Piter';
echo preg_replace("/($pattern)/i",$replacement,$subject);
?>
echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'; //輸出網頁編碼為 utf-8
$subject="Hi, My name is John. I love travel.";
$pattern='John';
$replacement='Piter';
echo preg_replace("/($pattern)/i",$replacement,$subject);
?>