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. preg_match_all($pattern_new, $content, $vals);
  10. print_r(array_map(function ($a) { return simpleConvert("AUD", "USD", $a); }, $vals[1]));
Success #stdin #stdout 0.01s 52488KB
stdin
Standard input is empty
stdout
Array
(
    [0] => USD 9999.95
    [1] => USD 99920.00
    [2] => USD 9990.00
    [3] => USD 9999.95
    [4] => USD 9999.95
    [5] => USD 99940
)