I am having a bit trouble to get only number from specific part of html code, i am parsing one page and output of content looks like this.
<div class="priceitem"> 1,098 USD <span id="XUwt-price-mb-aE068a15dcca8E168a15dcca8-tooltipIcon" class="tooltip-icon afterPrice info-icon"> <svg class="" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200" width="100%" height="100%"><use xlink:href="#common-icon-icon-info"></use></svg> </span> <br></div>
I am using simplehtmldom to get content, so everything inside priceitem get output with it. Can i somehow use preg_match to match pattern or preg_replace to get only price number like 1,098.
The price can change so sometimes it will be only 29 usd which will output 29 USD, sometimes price can be 305 USD, but over 1k it will have comma which i don't need really.
Here is my attempt on everything:
foreach($html->find('div.priceitem') as $element) {
$pricenum = preg_match("/([^\s]+)/","", $element->innertext);
echo $pricenum;
}