Jump to content

splitting html


gansad

Recommended Posts

I have a string = '<img alt="image_description" src="http://images.domain.com/path/image_name.jpg">'

Need help to split the string to:
a) return the alt entry only i.e. image_description
b) return the path entry i.e. if the src is at [a href=\"http://images.domain.com/path1/path2/image_name.jpg\" target=\"_blank\"]http://images.domain.com/path1/path2/image_name.jpg[/a], it will return path1/path2/ only.

thanks.
Link to comment
Share on other sites

[!--quoteo(post=369709:date=Apr 29 2006, 04:51 AM:name=gansad)--][div class=\'quotetop\']QUOTE(gansad @ Apr 29 2006, 04:51 AM) [snapback]369709[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I have a string = '<img alt="image_description" src="http://images.domain.com/path/image_name.jpg">'

Need help to split the string to:
a) return the alt entry only i.e. image_description
b) return the path entry i.e. if the src is at [a href=\"http://images.domain.com/path1/path2/image_name.jpg\" target=\"_blank\"]http://images.domain.com/path1/path2/image_name.jpg[/a], it will return path1/path2/ only.

thanks.
[/quote]

Tried this but not as wanted:

preg_match_all("/<img alt=\"([^']*?)\">/", $img, $matches);
print_r($matches);
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.