I am applying preg_match_all on a webpage select box that i get from file_get_contents but the problem is that it is only getting first select box and is not able to get second select box and it's options. My code is
$html = file_get_contents("https://www.amazon.co.jp/-/en/dp/B09C1PM7K3?th=1");
$quantityMatch = preg_match_all( '@(<option value="([^"]+)">([^<]+)</option>)@', $html, $quantity);
$result = array();
$k = 0;
foreach ($quantity[0] as $i => $value){
$result[$quantity[2][$i]] = $quantity[3][$i];
$k = $i;
}
$finalQty = $quantity[3][$k];
// print_r($result);
dd($finalQty);
it is getting categories from this page but i need second select box that is the quantity of stock on the webpage.