Ciao a tutti, prendo dal mio db un testo e vorrei confrontare questo testo con alcune regex se soddisfano tale condizione prendo tale testo e lo modifico invece tutto il resto lo lascio stare...
Vi posto il codice:
Vi posto il codice:
PHP:
preg_match("/(?:https?:\/\/)?(?:www\.)?youtu(?:\.be|be\.com)\/(?:watch\?v=)?(\w{10,})/",$row["text"],$matches);
if(isset($matches[1])){
$testo = preg_replace("/(?:https?:\/\/)?(?:www\.)?youtu(?:\.be|be\.com)\/(?:watch\?v=)?(\w{10,})/",'<br><object data="http://www.youtube.com/v/'.$matches[1].'&hl=it&fs=1&rel=0" type="application/x-shockwave-flash" width="320px" height="245px"><param name="movie" value="http://www.youtube.com/v/'.$matches[1].'&hl=it&fs=1&rel=0"></object>',$row["text"]);
}else{
preg_match('~(?:http?:\/\/)?(?:www\.)?vimeo\.com/(?:clip:)?(\d+)~',$row["text"],$matches);
if(isset($matches[1])){
$testo = preg_replace('~(?:http?:\/\/)?(?:www\.)?vimeo\.com/(?:clip:)?(\d+)~','<br><object width="320px" height="245px"><param name="allowfullscreen" value="true"><param name="allowscriptaccess" value="always"><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id='.$matches[1].'&server=vimeo.com&color=00adef&fullscreen=1"><embed src="http://vimeo.com/moogaloop.swf?clip_id='.$matches[1].'&server=vimeo.com&color=00adef&fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="320px" height="245px"></embed></object>',$row["text"]);
}else{
$testo = $row["text"];
}}