Hi i want to get Div's attribute value from a HTML content without using DOMDocument in PHP. here is my code:
<?php
$html = <<<HTML
<div class='viewBuyButt' onclick="javascript:window.location='https://somelink.com?sdf=fhasldfss';return false;"></div>
HTML;
?>
OUTPUT Expected:
https://somelink.com?sdf=fhasldfss
I tried with:
<?php
$pattern = '/<div class="viewBuyButt".*\sonclick="(.*?)">/';
preg_match($pattern, $html, $viewAllLink);
var_dump($viewAllLink);// but not getting output
any help will be greatly appreciated.