Jump to content


Photo

splitting html


  • Please log in to reply
2 replies to this topic

#1 gansad

gansad
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 28 April 2006 - 08:51 PM

I have a string = '<img alt="image_description" src="http://images.domain...mage_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.

#2 gansad

gansad
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 28 April 2006 - 09:33 PM

[!--quoteo(post=369709:date=Apr 29 2006, 04:51 AM:name=gansad)--][div class=\'quotetop\']QUOTE(gansad @ Apr 29 2006, 04:51 AM) View Post[/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);

#3 gansad

gansad
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 02 May 2006 - 03:02 AM

any one?
regex experts?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users