Jump to content

Extracting text


w1ww

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/141635-extracting-text/
Share on other sites

<?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];
  }
?>

Link to comment
https://forums.phpfreaks.com/topic/141635-extracting-text/#findComment-741421
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.