SHARE
TWEET

Untitled

a guest Sep 17th, 2019 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if (!function_exists('parseSMS')) {
  2.     function parseSMS(string $sms): ?array
  3.     {
  4.         preg_match('/\b\d{4}(?!,\d{2})\b/m', $sms, $password);
  5.  
  6.         if (!isset($password[0])) {
  7.             return null;
  8.         }
  9.  
  10.         preg_match('/\d{1,}(,|\.)\d{2}/m', $sms, $amount);
  11.  
  12.         if (!isset($amount[0])) {
  13.             return null;
  14.         }
  15.  
  16.         preg_match('/\d{13,16}/m', $sms, $wallet);
  17.  
  18.         if (!isset($wallet[0])) {
  19.             return null;
  20.         }
  21.  
  22.         return [
  23.             'password' => $password[0],
  24.             'amount' => (float)str_replace(',', '.', $amount[0]),
  25.             'wallet' => $wallet[0],
  26.         ];
  27.     }
  28. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top