Pregmatch help...

Started by Biology Forums, March 09, 2014, 08:23:26 PM

Previous topic - Next topic

Biology Forums

if (!empty($processed['body']) && preg_match('#(http://www.youtube.com)?/(v/([-|~_0-9A-Za-z]+)|watch\?v\=([-|~_0-9A-Za-z]+)&?.*?)#i', $processed['body'], $preg_text))

$processed['body'] = preg_replace('#(http://www.youtube.com)?/(v/([-|~_0-9A-Za-z]+)|watch\?v\=([-|~_0-9A-Za-z]+)&?.*?)#i', '<iframe width="560" height="315" src="http://www.youtube.com/embed/' . $preg_text . '" frameborder="0" allowfullscreen ></iframe>', $processed['body']);


I want to check if $processed['body'] contains any URL with the pattern '#(http://www.youtube.com)?/(v/([-|~_0-9A-Za-z]+)|watch\?v\=([-|~_0-9A-Za-z]+)&?.*?)#i' and if it does, it replaces that piece with <iframe width="560" height="315" src="http://www.youtube.com/embed/'; . $preg_text . '" frameborder="0" allowfullscreen ></iframe>... However, it keeps producing the following:

<iframe width="560" height="315" src="http://www.youtube.com/embed/ARRAY" frameborder="0" allowfullscreen ></iframe>

How do I accomplish what it is I want to do?

vbgamer45

Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Advertisement: