It will recursively check that given text is valid name or not.
Pattern Rules:
1. Only A to Z, a to z , space and - (dash) are allowed.
2. Repeated spaces, dashes (-) at once are now allowed.
<?php
/*
Validating the name (Recurcivly)
-----------------------------------------
(Logic/Pattern) Written by Junaid Atari
+ Examples:
- Muhammad
- Junaid Atari
- Sag-e-Attar
*/
//# Name to validate.
$name = 'Ali Attar';
echo preg_match ('/^([a-zA-Z]+)(?:[a-zA-Z]+[\s-]?)*$/', $name)
? 'Name is Valid'
: 'Name is not valid';
Pattern Rules:
1. Only A to Z, a to z , space and - (dash) are allowed.
2. Repeated spaces, dashes (-) at once are now allowed.
<?php
/*
Validating the name (Recurcivly)
-----------------------------------------
(Logic/Pattern) Written by Junaid Atari
+ Examples:
- Muhammad
- Junaid Atari
- Sag-e-Attar
*/
//# Name to validate.
$name = 'Ali Attar';
echo preg_match ('/^([a-zA-Z]+)(?:[a-zA-Z]+[\s-]?)*$/', $name)
? 'Name is Valid'
: 'Name is not valid';
0 comments:
Post a Comment