Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getData($str)
- {
- $number_reg = "/\d{11,16}\D?/";
- $amount_reg = "/(\d+[,.]\d{1,2}|\d{1,6})\s?[^0-9\s]{1,7}\s[\n]?/";
- $code_reg = "/\d{4,10}\s{0,2}/";
- $output = [];
- $result = [];
- preg_match($amount_reg, $str, $result);
- $output['amount'] = (double)str_replace(',', '.', preg_replace('/[^0-9,.]/', '', $result[1]));
- preg_match($number_reg, $str, $result);
- $output['num'] = ((int)$result[0]);
- preg_match($code_reg, $str, $result);
- $output['code'] = ((int)$result[0]);
- var_dump($output);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement