Skip to content

Instantly share code, notes, and snippets.

@gustawdaniel gustawdaniel/app.php
Created Mar 28, 2017

Embed
What would you like to do?
<?php
// config
$data = [
'email' => 'name@post.com',
'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
You can’t perform that action at this time.