Created
March 28, 2017 15:18
-
-
Save gustawdaniel/969f75156287c3cb1713a494808a8a87 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
// config | |
$data = [ | |
'email' => '[email protected]', | |
'url' => 'http://example.com', | |
'ip' => '123.15.12.211' | |
]; | |
// loop over data | |
foreach ($data as $key => $item) | |
{ | |
// validated contains string with value or false | |
$validated = filter_var( | |
$item, | |
constant('FILTER_VALIDATE_'.strtoupper($key)) | |
); | |
// echo validate | |
echo $validated . "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment