Advertisement
Guest User

Untitled

a guest
Apr 25th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * @param string $message
  5. * @return array
  6. */
  7. function parseYandexMoneySMS($message)
  8. {
  9. $message = mb_strtolower(strip_tags($message));
  10. $code = '';
  11. $purse = '';
  12. $amount = '';
  13. if(preg_match("/(?:[^\d]|^)(\d{4})(?!р|\sр|\d|[,.]\d)/", $message, $matches)) {
  14. $code = $matches[1];
  15. }
  16. if(preg_match("/(?:[^\d]|^)(41001(\d{6,15}))(?:[^\d]|$)/", $message, $matches)) {
  17. $purse = $matches[1];
  18. }
  19. if(preg_match("/(?:[^\d]|^)([\d,.\s]+)\s*р/", $message, $matches)) {
  20. $amount = (float) str_replace([',', ' '], ['.', ''], $matches[1]);
  21. }
  22. return [$code, $purse, $amount];
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement