[TOC] ## 替换单个 ``` $str ="hello word"; echo preg_replace("/h.*llo/",'idcpj',$str); //idcpjo word ``` ## 替换多个 ``` $str ="hello word this is a new word"; $pattern = ["/h.*llo/",'/t.*is/']; $replacement=['idcpj','that']; echo preg_replace($pattern,$replacement,$str); //idcpj word that a new word ```