Import users for Gmail

administrator

Administrator
Nhân viên
9 Tháng tám 2021
49
0
6
Cách lấy phone number từ text body:
Mã:
 // param 1: 0912345678 || +84 0912345678 || (+84) 0912345678 || +084-0912345678
                // return 1: 0912345678
                // param: +84 912345678
                // return: 84 912345678
                // param : 084 912345678 || +084 912345678
                // return: 084 912345678
                // param 2: 912345678 ||  (+084) 912345678 || +084-912345678
                // return 2: 912345678
                // param 3: 0912 345 678 || +84 0912 345 678 || (+84) 0912 345 678
                // return 3: 0912 345 678
                // param 4: 0912-345-678 || +84 0912-345-678 || (+84)-0912-345-678
                // return 4: 0912-345-678
                // else return: 000000000
                $textBody = $mail->getPlainTextBody();
                preg_match(
                    '/[0-9]{10}|[0-9]{2}[\s][0-9]{9}|[0-9]{3}[\s][0-9]{9}|[0-9]{9}|[0-9]{4}[\s][0-9]{3}[\s][0-9]{3}|[0-9]{4}[\-][0-9]{3}[\-][0-9]{3}/',
                    $textBody,
                    $phoneMails
                );
                if (isset($phoneMails[0])) {
                    $phones[] = $phoneMails[0];
                } else {
                    $phones[] = '0000000000';
                }