1

i want the content inside of the "img" tag from the string. for ex:- if

str="< img src="/files/thumbnails/001.simonhiggins_comm games_thumb.jpg" title="Commonwealth Games" alt="showreel" class="clear-right-margin" />"

then i want to o/p using preg_split as follows:-

src="/files/thumbnails/001.simonhiggins_comm games_thumb.jpg" title="Commonwealth Games" alt="showreel" class="clear-right-margin"

i used following code to find it out

$x = preg_split('/<img(.*?)>/',$p,-1,PREG_SPLIT_DELIM_CAPTURE);

but it is not working properly for some cases for ex:- if there is a space or a blank line inside the image tag.

Charles
  • 50,943
  • 13
  • 104
  • 142
Salil
  • 46,566
  • 21
  • 122
  • 156

1 Answers1

1

preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $data, $matches)

fire
  • 21,383
  • 17
  • 79
  • 114
  • sorry but it's not working my img tag is as follows "showreel " and i want something like following. src="/files/thumbnails/001.simonhiggins_comm games_thumb.jpg" title="Commonwealth Games " alt="showreel" class="clear-right-margin" – Salil Feb 12 '10 at 11:52
  • How about.. `preg_match('//', $data, $matches);` – fire Feb 12 '10 at 17:04