Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * @param string $message
- * @return array
- */
- function parseYandexMoneySMS($message)
- {
- $message = mb_strtolower(strip_tags($message));
- $code = '';
- $purse = '';
- $amount = '';
- if(preg_match("/(?:[^\d]|^)(\d{4})(?!р|\sр|\d|[,.]\d)/", $message, $matches)) {
- $code = $matches[1];
- }
- if(preg_match("/(?:[^\d]|^)(41001(\d{6,15}))(?:[^\d]|$)/", $message, $matches)) {
- $purse = $matches[1];
- }
- if(preg_match("/(?:[^\d]|^)([\d,.\s]+)\s*р/", $message, $matches)) {
- $amount = (float) str_replace([',', ' '], ['.', ''], $matches[1]);
- }
- return [$code, $purse, $amount];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement