Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4017984
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:55:39+00:00 2026-05-20T09:55:39+00:00

i am writing a php app that asks people for their phone number in

  • 0

i am writing a php app that asks people for their phone number in lebanon. I don’t want to be very strict in the entry format so i’m running into some trouble validating.

A lebanese phone number looks like that.

961 3 123456

961: the country code. i want it to be valid with or without it.

3: the area code. here’s where it is tricky. the possible area codes are 03, 70 and 71. when the country code is present, 03 drops the 0 and becomes 3 while 70 and 71 are as is with or without country code.

123456: the phone number, always 6 digits.

here are the formats i’m trying to validate:

961 3 123456
961 70 123456
961 71 123456
03 123456
70 123456
71 123456

the spaces are here just for the sake of clarity, i am validating after stripping all spaces and non alphanumeric characters.

that’s it, would be great if someone can help.
thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T09:55:39+00:00Added an answer on May 20, 2026 at 9:55 am

    I’m sure there’s a slicker way to do it, but

    ^(961(3|70|71)|(03|70|71))\d{6}$
    

    seems to work, assuming I understand the requirements.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing an app that will need to unzip user uploaded archives. PHP
I'm writing a simple web app in PHP that needs to have write access
I am writing a web app in PHP using mySQL that models an election.
I am writing a php app that interfaces with a companies SOAP API. I
I was writing a PHP (Kohana) app and I saw that the controller index
I am writing a php/mysql app that uses a few different tables. Table 1
I'm writing a PHP app that has a 'control panel' that writes a prefs
I'm writing a PHP app that integrates with Infusionsoft. I've googled my error and
I've been writing an iPhone app that could send JSON to a PHP file
Writing a PHP app and have several classes that only have static methods (no

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.