title: how to preg_match in php for numeric with fixed range?
body: <p>how can I preg_match in php for numeric with fixed range?</p>
  
  <p>I want to allow 8 digit number in text box without starting of 0.</p>
  
  <p>Eg-<strong>12345678</strong></p>
  
  <p>The following is my piece of code.</p>
  
  <pre><code>if(isset($_POST['submit1'])) {
      if(empty($_POST["phone"]))
   {
    $error .= '&lt;p&gt;&lt;label class="text-danger"&gt;Please Enter your phone number&lt;/label&gt;&lt;/p&gt;';
   }
   else{
       if(!preg_match("/^[1-9][0-9]{8}$/",$PhNum))
    {
     $error .= '&lt;p&gt;&lt;label class="text-danger"&gt;Only 8 digit numbers are allowed&lt;/label&gt;&lt;/p&gt;';
    }
   }
  }
  </code></pre>
  
  <p>Thanks.</p>