GSTIN syntax validation in PHP

0
441
PHP

This example explains how to validate GSTIN syntax in PHP.

<?php

  function check_gstin($number)
    {
        if(!preg_match("/^(0[1-9]|[1-2][0-9]|3[0-9])([a-zA-Z]){5}([0-9]){4}([a-zA-Z]){1}([a-zA-Z0-9]){1}([a-zA-Z]){1}([a-zA-Z0-9]){1}?$/", $number)) {
   
    return "1";
    } 
    else 
    {
        return "0";
    }
    }
$gstin="08EPDPS3879MJZ5"; 
 $gst_check=check_gstin($gstin);
 if($gst_check=="1")
                        {
                             echo "Syntax not Matched.";
                        }
?>

LEAVE A REPLY

Please enter your comment!
Please enter your name here