国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

PHP實現通過正則表達式替換回調的內容標簽

2024-05-04 23:36:14
字體:
來源:轉載
供稿:網友

這篇文章主要介紹了PHP實現通過正則表達式替換回調的內容標簽的方法,涉及php正則匹配與替換的相關技巧,需要的朋友可以參考下

本文實例講述了PHP實現通過正則表達式替換回調的內容標簽。分享給大家供大家參考。具體實現方法如下:

 

 
  1. function my_wp_plugin_tag_action($content,$tag,$function,$args = FALSE) { 
  2. // match all regular expressions 
  3. preg_match_all($tag,$content,$matches); 
  4. if (count($matches)>0) { 
  5. // filter duplicates 
  6. $matches = array_unique($matches); 
  7. // loop through 
  8. $tag_results = array(); 
  9. $found_tags = array(); 
  10. foreach ($matches as $idx => $match) { 
  11. //build arg array 
  12. $full_tag = array_shift($match); 
  13. //call function, adding function output and full tag text to replacement array 
  14. $tag_results[] = my_wp_plugin_buffer_func($function,$match); 
  15. $found_tags[] = $full_tag
  16. // replace all tags with corresponding text 
  17. $content = str_replace($found_tags,$tag_results,$content); 
  18. return $content

希望本文所述對大家的php程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 周宁县| 吉安市| 乐清市| 朝阳县| 太谷县| 崇州市| 长乐市| 攀枝花市| 禄丰县| 彭泽县| 淅川县| 布拖县| 桂平市| 黄平县| 会理县| 宁蒗| 石柱| 无极县| 兴和县| 庐江县| 襄汾县| 敖汉旗| 白玉县| 延津县| 五家渠市| 蒙自县| 齐齐哈尔市| 庄河市| 天水市| 英德市| 大理市| 南澳县| 彭州市| 扶风县| 大关县| 明水县| 鱼台县| 申扎县| 隆德县| 灵丘县| 吉安市|