I want to replace certain html tags with null string and want to retrieve text only. Below is the example that I want.
preg_match_all("/<span id=\"priceblock_ourprice\" class=\"a-size-medium a-color-price\">(.*)<\/span>/U", $content, $matches);
The above line retrieves something like this.
<span id="priceblock_ourprice" class="a-size-medium a-color-price">50</span>
Now, I want to retrieve the integer value only (i.e 50). I tried the following statement to remove the HTML tags.
foreach($matches[0] as $key=>$val) {
$price = preg_replace( '/<(.*)>/', '', $val);
}
But the problem is, it replaces everything, and a null string is returned. It should return 50, no the null. The output file $price variable should be like:
$price = 50