Skip to content
WJunction - Webmaster Forum

php help regex!

Status
Not open for further replies.
i have to do a simple work

i have to find all <youtube>v=xxxxxx</youtube> in post of a wordpress

and replace then custom way!

Code:
function the_content($more_link_text = null, $stripteaser = 0) {
    $content = get_the_content($more_link_text, $stripteaser);
    $content = apply_filters('the_content', $content);
    $content = str_replace(']]>', ']]&gt;', $content);
    
    preg_match_all('#<youtube>(.*?)</youtube>#i', $content, $link_matches);
    if (count($link_matches) > 0){
        foreach ($link_matches as $link_value){
            echo $link_value;

        }
              
    }
    
    
    return $content;
}
this function is in post-template.php in wp-include folder.

pls help!
 
Last edited:

7 comments

(
[0] =&gt; Array
(
[0] =&gt; <youtube>1</youtube> [1] =&gt; <youtube>100</youtube> [2] =&gt; <youtube>1000</youtube> [3] =&gt; <youtube>10000</youtube> [4] =&gt; <youtube>100000</youtube> [5] =&gt; <youtube>1000000</youtube> [6] =&gt; <youtube>10000000</youtube> [7] =&gt; <youtube>100000000</youtube> )
[1] =&gt; Array
(
[0] =&gt; 1
[1] =&gt; 100
[2] =&gt; 1000
[3] =&gt; 10000
[4] =&gt; 100000
[5] =&gt; 1000000
[6] =&gt; 10000000
[7] =&gt; 100000000
)
)

The message you have entered is too short. Please lengthen your message to at least 8 characters.
 
change this:

preg_match_all('#<youtube>(.*?)</youtube>#i', $content, $link_matches);

to this:

preg_match_all('#<youtube>(.*?)<\/youtube>#i', $content, $link_matches);

if it still won't work... then post the error which you get.
 
Status
Not open for further replies.

About the author

•
Active Member · Joined
VB6 Programmer gaming
389
Messages
132
Reactions
43
Points

Advertise on WJunction

Reach 1000's of webmasters, hosts & affiliates. Banner & sponsored-thread slots available.

Contact us
Back
Top Bottom