$string = "Welcome to";

var_dump(filter_var($string, FILTER_VALIDATE_REGEXP,
Output is
string(23) "Welcome to"
By using FILTER_VALIDATE_REGEXP we can validate Regular expression .

Change the $string variable value to
$string="ZWelcome to";
Output is now

Example 2

$string = "Welcome to"; // change the first char and see the result

if(filter_var($string, FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>"/^W(.*)/")))){
echo "yes Cleared ";	
echo " No not cleared ";	
Output is here
yes Cleared
Filter reference Validating Boolean data Ctype_alnum to check alphanumeric characters Validating Email address
Subscribe to our YouTube Channel here


* indicates required
Subscribe to plus2net

    Post your comments , suggestion , error , requirements etc here

    PHP video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 All rights reserved worldwide Privacy Policy Disclaimer