-2

i need to get href value from class name like that.

some one can give me regex to find this class name and get from there the href ?

<a href='http://www.tovtoda.co.il/BusinessPage.aspx?b=6973' class="boldOrange"></a>

thanks alot

Alex Andrei
  • 7,315
  • 3
  • 28
  • 42

1 Answers1

4

You can do this using DomDocument and XPath, see here

$str = '<a href="http://www.tovtoda.co.il/BusinessPage.aspx?b=6973" class="boldOrange"></a>';

$doc = new DOMDocument();
$doc->loadHTML($str);
$xpath = new DOMXPath($d);
$links = $xpath->query('//a[@class="boldOrange"]');

foreach ($links as $link) {
    $url = $link->getAttribute('href');
    print $url . PHP_EOL;
}
Alex Andrei
  • 7,315
  • 3
  • 28
  • 42