php - preg_match_all function to clip integers -
<div class="final-pro" itemprop="pro"> <meta itemprop="curr" content="yen"> <span style="font-family: yen">d </span>15,675 <span class="base-pro linethrough"> <span style="font-family: yen">d </span>14,999 </span> </div>
i need clip values 15,675 , 14,999 above html codes using preg_match_all. tried as possible failed.helping hands welcome.
what i've tried far:
preg_match_all('/yen">d </span>(.*?)<\span/s',$con,$val);
$txt = '<div class="final-pro" itemprop="pro"> <meta itemprop="curr" content="yen"> <span style="font-family: yen">d </span>15,675 <span class="base-pro linethrough"> <span style="font-family: yen">d </span>14,999 </span> </div>'; $matches = array(); preg_match_all('/[0-9,]+/', $txt, $matches); print_r($matches);
it [0-9,]+
looks numbers , ,
that's all.
output
array ( [0] => array ( [0] => 15,675 [1] => 14,999 ) )
if need more complicated regex fit needs can use
preg_match_all('/font-family: yen">d <\/span>([0-9,]+)/', $txt, $matches);
edit:
if want find these numbers in whole div regex needs more complicated
preg_match('/<div class\="final\-pro" itemprop="pro">.*?<\/span>([0-9,]+).*?<\/span>([0-9,]+).*?<\/div>/s', $txt, $matches);
take @ /s
modifier enables "single-line mode". in mode, dot matches newlines.
Comments
Post a Comment