Skip to content

Instantly share code, notes, and snippets.

@gustawdaniel
Created March 28, 2017 15:18
Show Gist options
  • Save gustawdaniel/969f75156287c3cb1713a494808a8a87 to your computer and use it in GitHub Desktop.
Save gustawdaniel/969f75156287c3cb1713a494808a8a87 to your computer and use it in GitHub Desktop.
<?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