fork download
  1. <?php
  2.  
  3. $html = <<<XXX
  4. <div id="isOffered">
  5.   <a class="price addBetButton footballBetButton" id="bk_82285689_mk_sel1" href="">
  6.   <span class="priceText wide UK">1/2</span>
  7.   <span class="priceText wide EU">1.50</span>
  8.   <span class="priceText wide US">-200</span>
  9.   <span class="priceText wide CH">1.50</span>
  10.   <span class="priceChangeArrow"></span>
  11.   <input class="betCode" type="hidden" value="0]SK@82285689@314222649@NB*1~2*0*-1*0*0]CPN:0" />
  12.   <input class="originalBetCode" type="hidden" value="0]SK@82285689@314222649@NB*1~2*0*-1*0*0]CPN:0" />
  13.   </a>
  14. </div>
  15. XXX;
  16.  
  17. $re = "/(span.*pricetext.*>)([\d\/.-]+)/im";
  18.  
  19. $ret = preg_replace_callback($re, function($matches){
  20. $matches[2] = ((float)$matches[2]) * .8;
  21. return $matches[1] . $matches[2];
  22. }, $html);
  23.  
  24. echo $ret;
Success #stdin #stdout 0.01s 24400KB
stdin
Standard input is empty
stdout
<div id="isOffered">
   <a class="price addBetButton footballBetButton" id="bk_82285689_mk_sel1" href="">
   <span class="priceText wide UK">0.8</span>
   <span class="priceText wide EU">1.2</span>
   <span class="priceText wide US">-160</span>
   <span class="priceText wide CH">1.2</span>
   <span class="priceChangeArrow"></span>
   <input class="betCode" type="hidden" value="0]SK@82285689@314222649@NB*1~2*0*-1*0*0]CPN:0" />
   <input class="originalBetCode" type="hidden" value="0]SK@82285689@314222649@NB*1~2*0*-1*0*0]CPN:0" /> 
   </a>
</div>