php regex get first youtube id form text -
how get:
wa4nndfq0wa
form code:
<p>some text here ...</p> <iframe width="640" height="360" src="//www.youtube.com/embed/wa4nndfq0wa?feature=player_embedded" frameborder="0" allowfullscreen></iframe> <div>some text here ...</div> <iframe width="640" height="360" src="//www.youtube.com/embed/9gypdwa6r2s?feature=player_embedded" frameborder="0" allowfullscreen></iframe>
by using php?
assuming html inside $html
variable.
preg_match("|.*?/embed/([\w-]+)|", $html, $m); print $m[1];
if change .*?
.*
(greedy) match last id.
Comments
Post a Comment