Created
December 5, 2012 19:33
-
-
Save davidkryzaniak/4218778 to your computer and use it in GitHub Desktop.
Example of filter_var()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Lists the available filters you can select from | |
print_r(filter_list()); | |
//returns 100000000.10 | |
echo filter_var("$100,000,000.10", FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); | |
//returns -23423 | |
echo filter_var("-2,3423.2343", FILTER_SANITIZE_NUMBER_FLOAT); | |
//returns null | |
echo filter_var('test-at-test.com', FILTER_VALIDATE_EMAIL); | |
//returns test@test.com | |
echo filter_var('test@test.com', FILTER_VALIDATE_EMAIL); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment