我想在电话号码变量$toNumbers前面添加数字1“1”。我已经尝试了PHP字符串
$toNumbers = '1'.$toNumbers;
在电话号码前附加1,但无法使其生效。我在这里做错了什么?
下面是来自vTiger SMS模块的,我需要在数字格式前面加一个1,以便发送。我想在每个数字前面加上1,以便短信模块正确发送。问题是,我的所有电话号码都存储为(xxx)xxx-xxxx,而不是1(xxx)xxx-xxx。
public function send($message, $toNumbers) {
if(!is_array($toNumbers)) {
$toNumbers = '1'.$toNumbers;
$toNumbers = array($toNumbers);
}
$params = $this->prepareParameters();
$params['text'] = $message;
$params['to'] = implode(',', $toNumbers);
$serviceURL = $this->getServiceURL(self::SERVICE_SEND);
$httpClient = new Vtiger_Net_Client($serviceURL);
$response = $httpClient->doPost($params);
$responseLines = split("\n", $response);
$results = array();
$i=0;
foreach($responseLines as $responseLine) {
$responseLine = trim($responseLine);
if(empty($responseLine)) continue;
$result = array( 'error' => false, 'statusmessage' => '' );
if(preg_match("/ERR:(.*)/", trim($responseLine), $matches)) {
$result['error'] = true;
$result['to'] = $toNumbers[$i++];
$result['statusmessage'] = $matches[0]; // Complete error message
} else if(preg_match("/ID: ([^ ]+)TO:(.*)/", $responseLine, $matches)) {
$result['id'] = trim($matches[1]);
$result['to'] = trim($matches[2]);
$result['status'] = self::MSG_STATUS_PROCESSING;
} else if(preg_match("/ID: (.*)/", $responseLine, $matches)) {
$result['id'] = trim($matches[1]);
$result['to'] = $toNumbers[0];
$result['status'] = self::MSG_STATUS_PROCESSING;
}
$results[] = $result;
}
return $results;
}