本文實(shí)例講述了PHP實(shí)現(xiàn)通過正則表達(dá)式替換回調(diào)的內(nèi)容標(biāo)簽。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 function my_wp_plugin_tag_action($content,$tag,$function,$args = FALSE) { // match all regular expressions preg_match_all($tag,$content,$matches); if (count($matches)>0) { // filter duplicates $matches = array_unique($matches); // loop through $tag_results = array(); $found_tags = array(); foreach ($matches as $idx => $match) { //build arg array $full_tag = array_shift($match); //call function, adding function output and full tag text to replacement array $tag_results[] = my_wp_plugin_buffer_func($function,$match); $found_tags[] = $full_希望本文所述對大家的php程序設(shè)計有所幫助。
新聞熱點(diǎn)
疑難解答
圖片精選