Had a look round but couldn’t find a working (and recent) solution for this.
Using an API I am receiving a string like this:
<object width="600" height="338">
<param name="movie" value="http://www.youtube.com/v/ItT88H3nAWw?version=3&feature=oembed"></param>
<param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube.com/v/ItT88H3nAWw?version=3&feature=oembed" type="application/x-shockwave-flash" width="600" height="338" allowscriptaccess="always" allowfullscreen="true"></embed>
</object>
What would be a regular expression in PHP to extract just the video id? e.g. ItT88H3nAWw
Get
srcparam fromembedtag WITHOUT regexp. Then parse it in following way:This regexp will handle both:
To convert HTML string to an object use
SimpleXMLElement.