Ben, youtube embed kodu üzerinden video bağlantısı ayıklamak istiyorsanız, bunun için bir regex çözüm arıyorum

2 Cevap php

Örneğin: Bir youtube embed kodu

<object width="480" height="385">
        <param name="movie" value="http://www.youtube.com/v/TFlzeO267qY&hl=en_US&fs=1&"></param>
        <param name="allowFullScreen" value="true"></param>
        <param name="allowscriptaccess" value="always"></param>
        <embed src="http://www.youtube.com/v/TFlzeO267qY&hl=en_US&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed>
</object>

Ben bu embed kodu http://www.youtube.com/v/TFlzeO267qY&hl=en_US&fs=1&" çıkarmak istiyorum ama bunun için bir regex ifade oluşturmak için nasıl bilmiyorum

Şimdiden teşekkürler?

2 Cevap

Ben bu kodu ne gerek .. bunu denemek ve belki de anlamak için yardımcı olacaktır emin değilim regex :

$var = '<object width="480" height="385">
        <param name="movie" value="http://www.youtube.com/v/TFlzeO267qY&hl=en_US&fs=1&"></param>
        <param name="allowFullScreen" value="true"></param>
        <param name="allowscriptaccess" value="always"></param>
        <embed src="http://www.youtube.com/v/TFlzeO267qY&hl=en_US&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed>
</object>';
preg_match('/src="(.*?)"/', $var, $src);
$src = $src[1];
echo $src;

Bu sağlanan örnek bağlantı için çalışması gerekir:

http://(?:www\.)?youtube\.com/v/[\w&=]+

Onlar hala regex parçası böylece eğik kaçmak gerekir.