w1ww Posted January 20, 2009 Share Posted January 20, 2009 Hello, Can you guys help me a little bit with this (PHP). Imagine that I've this html code: <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="437" height="288" id="viddler_aae0f0d6"><param name="movie" value="http://www.viddler.com/player/aae0f0d6/" /><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /><embed src="http://www.viddler.com/player/aae0f0d6/" width="437" height="288" type="application/x-shockwave-flash" allowScriptAccess="always" allowFullScreen="true" name="viddler_aae0f0d6" ></embed></object> I want to extract the id field id="viddler_aae0f0d6". How can I do this knowing that every time the id it's going to be different? So basically I want to extract "viddler_aae0f0d6" from this code. Anyone has ideas? I know that this can de done with regular expressions but I'm not sure of how to do it. Regards! Quote Link to comment Share on other sites More sharing options...
rhodesa Posted January 20, 2009 Share Posted January 20, 2009 <?php $html = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="437" height="288" id="viddler_aae0f0d6"><param name="movie" value="http://www.viddler.com/player/aae0f0d6/" /><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /><embed src="http://www.viddler.com/player/aae0f0d6/" width="437" height="288" type="application/x-shockwave-flash" allowScriptAccess="always" allowFullScreen="true" name="viddler_aae0f0d6" ></embed></object>'; if(preg_match('/<object[^>]*id="(\w+)"/',$html,$matches)){ print $matches[1]; } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.