fork download
  1. <?php
  2.  
  3. $string = <<<DATA
  4. $50 From here i need only 50
  5. $60.59 From here i need only 60, Need to remove $ and .59
  6. €360 From here i need only 360.
  7. €36.99 From here i need only 36 need to remove € and .99.
  8. £900 From here i need only 900.
  9. £90.99 From here i need only 90.
  10. DATA;
  11.  
  12. $regex = '~[$€£]\K\d+~';
  13.  
  14. preg_match_all($regex, $string, $amounts);
  15. print_r($amounts);
  16.  
  17. ?>
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
Array
(
    [0] => Array
        (
            [0] => 50
            [1] => 60
            [2] => 360
            [3] => 36
            [4] => 900
            [5] => 90
        )

)