I want to test if an input is of the type 1234567 (7 digits). I use
preg_match($pattern,$subject);
where
$pattern = '/^[0-9]{7}$/';
However I get 1 for the case where the subject is
L-8987765
Which I do not want. How can I overcome this?
function isDocid($documento_id)
{
$subject = pg_escape_literal($documento_id);
$pattern1 = '/^[0-9]{7}$/';
if (preg_match($pattern1, $subject) === 1)
{
return 1;
}
else
{
return 0;
}}
$test_carta = isDocid('L-8987765');
echo('<p> ja existe docid '. $test_carta .'</p>');
I am expecting: ja existe docid 0