Re: extract price by preg_match_all

From: Date: Mon, 14 Feb 2011 16:12:48 +0000
Subject: Re: extract price by preg_match_all
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-311278@lists.php.net to get a copy of this message
<?php if ( preg_match_all("/([0-9]+[,\.]{1}[0-9]{2})/", $data, $matches) ) { echo "Matches found:"; echo "<pre>"; print_r($matches); echo "</pre>"; } else { echo "Didn't find anything..."; } ?> Untested. /frank 14 feb 2011 kl. 15.05 skrev Tontonq Tontonq: > example data: > > <div class="picboxfooter"> > <span class="newprice"><span class="productOldPrice">old price > 829,00 > &euro;</span><br />your price 58,90 &euro; *</span> > </div> > > another : > <span class="newprice"> 9,90 &euro; *</span> > > i want to extract 829,.00 & 58,90 from first source , 9,90 from the second > > i tried many way like preg_match_all('/<span > class="newprice">(\$[0-9,]+(\.[0-9]{2})?)<\/span>/',$data,$prices); > it doesn't work

« previous php.general (#311278) next »