title: Validate TelephoneNumber PHP
body: <p>I was given a task to validate a telephone number (stored in the var $number) introduced by a user in my website</p>
  
  <pre><code>$number = $_POST["telephone"];
  </code></pre>
  
  <p>The thing is this validation is quite complex as i must validate the number to see if it is from Portugal. i thought about validating it using all the indicators from Portugal, which are 52: (50 indicators are 3 digits long and 2 indicators are 2 digits long) Example of a number:</p>
  
  <p>254872272 (254 is the indicator)</p>
  
  <p>i also thought about making an array with all the indicators and then with a cycle verificate somehow if the first 2/3 digits are equal to the ones in the array.</p>
  
  <p>what do you guys think? how should i solve this problem?</p>