Skip to content

Instantly share code, notes, and snippets.

@davidkryzaniak
Created December 5, 2012 19:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidkryzaniak/4218778 to your computer and use it in GitHub Desktop.
Save davidkryzaniak/4218778 to your computer and use it in GitHub Desktop.
Example of filter_var()
<?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