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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.