-5

重複の可能性:
PHPフォームでモバイル番号をVALIDATEするのを手伝ってください

検証する携帯電話番号を取得しましたが、プレフィックス部分で立ち往生しています。

if(empty($_POST['mobileno'])) // phone number is not empty
{
$error[] = 'Please enter mobile number';
} else {
if(preg_match('/^\d{10}$/',$_POST['mobileno'])) // phone number is valid
{
  $mobile = $_POST['mobileno'];
  // your other code here
}
else // phone number is not valid
{
  $error[] = 'Phone number invalid !';
}
}
$prefix = 0;
$pmobile = $prefix . $mobile;

これは私がプレフィックスのためにやろうとしていることです。数値の前に値 0 を追加できないので、これは正しいですか。

4

1 に答える 1

0

正規表現を使ってみましたか?

 //check the first section is singular or multi, check area code between 0 and 9, check any additional integers
 $pattern = "[0|00]+[0-9]+[^\\s]";
 $phone_number = "000263712702879"; //international phone number
 if(preg_match($pattern, $phone_number)) {
      echo "this is a number";
 } else echo "this not a number";
于 2012-08-02T23:01:37.047 に答える