久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網
      最全最豐富的資訊網站

      php中preg_replace怎么替換變量數(shù)據(jù)

      在php中,“preg_replace”函數(shù)可以執(zhí)行一個正則表達式的搜索和替換來替換變量數(shù)據(jù),語法為“preg_replace(規(guī)定搜索的模式,用于替換的字符串或字符串數(shù)組,要搜索替換的目標字符串或字符串數(shù)組,字符串的最大可替換次數(shù),替換執(zhí)行的次數(shù))”;若subject是一個數(shù)組則返回的結果是一個數(shù)組,否則返回字符串。

      php中preg_replace怎么替換變量數(shù)據(jù)

      本文操作環(huán)境:Windows10系統(tǒng)、PHP8.1版、Dell G3電腦

      php中preg_replace怎么替換變量數(shù)據(jù)

      preg_replace 函數(shù)執(zhí)行一個正則表達式的搜索和替換。

      語法

      mixed preg_replace ( mixed $pattern , mixed $replacement , mixed $subject [, int $limit = -1 [, int &$count ]] )

      搜索 subject 中匹配 pattern 的部分, 以 replacement 進行替換。

      參數(shù)說明:

      • $pattern: 要搜索的模式,可以是字符串或一個字符串數(shù)組。

      • $replacement: 用于替換的字符串或字符串數(shù)組。

      • $subject: 要搜索替換的目標字符串或字符串數(shù)組。

      • $limit: 可選,對于每個模式用于每個 subject 字符串的最大可替換次數(shù)。 默認是-1(無限制)。

      • $count: 可選,為替換執(zhí)行的次數(shù)。

      返回值

      如果 subject 是一個數(shù)組, preg_replace() 返回一個數(shù)組, 其他情況下返回一個字符串。

      如果匹配被查找到,替換后的 subject 被返回,其他情況下 返回沒有改變的 subject。如果發(fā)生錯誤,返回 NULL。

      示例如下:

      <?php $string = 'The quick brown fox jumped over the lazy dog.'; $patterns = array(); $patterns[0] = '/quick/'; $patterns[1] = '/brown/'; $patterns[2] = '/fox/'; $replacements = array(); $replacements[2] = 'bear'; $replacements[1] = 'black'; $replacements[0] = 'slow'; echo preg_replace($patterns, $replacements, $string); ?>

      執(zhí)行結果如下所示:

      php中preg_replace怎么替換變量數(shù)據(jù)

      推薦學習:《PHP視頻教程》

      贊(0)
      分享到: 更多 (0)
      網站地圖   滬ICP備18035694號-2    滬公網安備31011702889846號