title: Validate Phone Prefix With Country Code : IF vs RegEx
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/5212341/php-regex-for-lebanese-phone-number">PHP regex for Lebanese phone number</a><br>
    <a href="https://stackoverflow.com/questions/11651744/preg-replace-to-mask-parts-of-a-phone-number">preg_replace to mask parts of a phone number</a>  </p>
  </blockquote>
  
  
  
  <p>in my country, there are 3 possibilities input for phone number prefix : +62, 62 and 0.</p>
  
  <p>for example : </p>
  
  <blockquote>
    <p>+622112345, 622112345 and 02112345</p>
  </blockquote>
  
  <p>now, the problem is... I want to store phone number in just 1 format, that is : 0xxxx. means, any phone prefix will be converted into 0xxxx format.</p>
  
  <blockquote>
    <p>Input : +622112345, Output : 02112345</p>
    
    <p>Input : 622112345, Output : 02112345</p>
    
    <p>Input : 02112345, Output : 02112345</p>
  </blockquote>
  
  <p>I thought by using substr() function and IF will solve this situation :</p>
  
  <pre><code>$Prefix = substr($Number, 0, 2);
  
  if ($Prefix = "+6"){
  //some code to convert +62 into 0
  }else if ($Prefix = "62"){
  //some code to convert 62 into 0
  }else{
  //nothing to do, because it's already 0
  }
  </code></pre>
  
  <p>is there any methods to do this beside using IF? with RegEx, for example...</p>