fork download
  1. <?php
  2.  
  3. function simpleConvert($from,$to,$amount)
  4. {
  5. return "USD 999" . $amount;
  6. }
  7. $content = "The following fees and deposits are charged by the property at time of service, check-in, or check-out.\r\n\r\nBreakfast fee: between AUD 9.95 and AUD 20.00 per person (approximately)\r\nFee for in-room wireless Internet: AUD 0.00 per night (rates may vary)\r\nFee for in-room high-speed Internet (wired): AUD 9.95 per night (rates may vary)\r\nFee for high-speed Internet (wired) in public areas: AUD 9.95 per night (rates may vary)\r\nLate check-out fee: AUD 40\r\nRollaway beds are available for an additional fee\r\nOnsite credit card charges are subject to a surcharge\r\nThe above list may not be comprehensive. Fees and deposits may not include tax and are subject to change.";
  8. $pattern_new = '/\bAUD (\d*\.?\d+)/';
  9. $res = preg_replace_callback($pattern_new, function($m) {
  10. return simpleConvert("AUD","USD",$m[1]);
  11. }, $content);
  12. echo $res;
  13.  
  14. preg_match_all($pattern_new, $content, $vals);
  15. print_r($vals[1]);
Success #stdin #stdout 0.01s 52488KB
stdin
Standard input is empty
stdout
The following fees and deposits are charged by the property at time of service, check-in, or check-out.

Breakfast fee: between USD 9999.95 and USD 99920.00 per person (approximately)
Fee for in-room wireless Internet: USD 9990.00 per night (rates may vary)
Fee for in-room high-speed Internet (wired): USD 9999.95 per night (rates may vary)
Fee for high-speed Internet (wired) in public areas: USD 9999.95 per night (rates may vary)
Late check-out fee: USD 99940
Rollaway beds are available for an additional fee
Onsite credit card charges are subject to a surcharge
The above list may not be comprehensive. Fees and deposits may not include tax and are subject to change.Array
(
    [0] => 9.95
    [1] => 20.00
    [2] => 0.00
    [3] => 9.95
    [4] => 9.95
    [5] => 40
)