I am hitting a road block with a script I have to check availability on a certain website. I need the text within html tags and I am unsure how to approach it.
My code I have tested ended with this:
<?php
ini_set("allow_url_fopen", 1);
$homepage2 = file_get_contents('https://www.someurlwithavailability.com');
//URL has the following HTML tag: <div id="Availability">
Availability: Special Offer, ships within 10 - 15 business days </div>"
preg_match("/<div id="Availability">(.*?)</div>/si", $homepage2, $avail);
print_r($avail);
echo '<br>', '~Availability is~', '<br>', $avail, '<br>';
$stringavail=implode(" ",$avail);
echo $stringavail;
?>
I get various errors depending on what I put after preg_match(***,$homepage2, $avail); and I am unsure about what syntax I need to enter to retrieve the text.
My code above gives me this:
Parse error: syntax error, unexpected 'Availability' (T_STRING) in /u/o/placeiamrunningthecodefrom.php on line 6
The URL that is requested comes back with a full HTML page that is quite large. This HTML tag is unique and does not repeat.
Anyone able to help me out?