Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (!function_exists('parseSMS')) {
- function parseSMS(string $sms): ?array
- {
- preg_match('/\b\d{4}(?!,\d{2})\b/m', $sms, $password);
- if (!isset($password[0])) {
- return null;
- }
- preg_match('/\d{1,}(,|\.)\d{2}/m', $sms, $amount);
- if (!isset($amount[0])) {
- return null;
- }
- preg_match('/\d{13,16}/m', $sms, $wallet);
- if (!isset($wallet[0])) {
- return null;
- }
- return [
- 'password' => $password[0],
- 'amount' => (float)str_replace(',', '.', $amount[0]),
- 'wallet' => $wallet[0],
- ];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement