Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Utility;
- class Utility
- {
- //... Declaration of Constants
- //... Declaration of curlExchangeRates function
- protected function processExchangeRates(string $curlResponse, \DateTime $earliestDate = null){
- $delimiter = ($earliestDate ? $earliestDate : new \DateTime('-20 years'))->format('n/j/Y');
- //split the string into an array based on the delimiter. The first string in the array is the rate string we need
- $ratesString = preg_split(sprintf('("%s")',$delimiter), $curlResponse, 2)[0];
- $headerPattern = '("Rate Date","Currency","Rate Year","Rate Month","Buying Rate","Central Rate","Selling Rate"\r\n)';
- //remove the first line in our rate string and return the result
- return preg_replace($headerPattern, '', $ratesString);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement