Validate phone number

Chek if a phone numbers is valid, according to its syntax (should be: "+390523599314"). True if it's valid, False otherwise

function is_valid_phone( $phone ) 
{
   if ( $phone[0] != "+" ) {
      return false;
   } // end if
   else {
      $phone = substr( $phone, 1 ); // delete the "+"
      if ( !is_numeric( $phone ) ) {
         return false;
      } // end if
   } // end else
   return true;
} // end function is_valid_phone

Tags

No tag here.

Recommended pages

Gregorian to Persian Date Convertor...

Gregorian to Persian Date Convertor....

Detect leap year...

Detect leap year for gregorian and shamsi date. function gLeapYear($year) { if (($year % 4 == 0) and (($year % 100 != 0) or ($year % 400 == 0))) return true; else return ...

Get all subsets of array...

If you have a list of items (for example)......

Download a file from web to local...

Use this function to download a file from web to local machine. function WgetFile( $URL, $dir ) { $nomefile = $dir . "/" . basename( $URL ); if ( copy( $URL, $nomefile ) ) { retu...