0

I need to get a Movie rating form from IMDB form image alt

<img width="44" height="15" title="PG_13" class="absmiddle" src="http://i.media-imdb.com/images/SF9c87441dc1ac3081c7de5a78d8864764/certificates/us/pg_13.png" **alt="PG_13"**>

My Code (WRONG):

$arr['rate'] = $this->match('/<img class=\"absmiddle\" src=\"\(.*?)\" alt=\"\(.*?)">/ms', $html, 1);
Abudayah
  • 3,816
  • 7
  • 40
  • 60
  • take a look at this answer http://stackoverflow.com/questions/138313/how-to-extract-img-src-title-and-alt-from-html-using-php – Babblo Apr 28 '12 at 16:58

1 Answers1

0
$text = '<img width="44" height="15" title="PG_13" class="absmiddle" src="http://i.media-imdb.com/images/SF9c87441dc1ac3081c7de5a78d8864764/certificates/us/pg_13.png" alt="PG_13">';
preg_match('<img[^<]+class="absmiddle" src="([^"]+)" alt="([^"]+)"/i', $text, $a);
$src = $a[1];
$alt = $a[2];
James C
  • 14,047
  • 1
  • 34
  • 43