I want to validate mobile number of 10 digits and also add a prefix of 0 when I enter into the database.
Have you tried a regular expression like:
if( !preg_match("/^([0-1]-)?[0-9]{3}-[0-9]{3}-[0-9]{4}$/i", $phone) ) { echo 'Please enter a valid phone number'; }