Change phone number before sending data to CRM
Example of trimming a number and substituting 8 at the beginning
$phone = $params['phone'];
// Getting the last 10 digits of the number
if(preg_match('/([0-9]{10})$/', $phone, $match)){
// if the number has 10 digits at the end, then add an eight to the beginning
$phone = '8' . $match[1];
}
return array(
'state' => 'success',
'data' => array(
'phone' => $phone,
),
);Last updated