Cleaned up example.

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@322557 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Justin Martin 2012-01-22 00:18:10 +00:00
parent 8a3d8d125a
commit b3445eefdd

View file

@ -73,11 +73,15 @@ $var = filter_var('oops', FILTER_VALIDATE_BOOLEAN,
function foo($value)
{
// Expected format: Surname, GivenNames
if (strpos($value, ", ") === false) return false;
list($surname, $givennames) = explode(", ", $value, 2);
if(
!(empty($surname) || empty($givennames))
&& (is_string($surname) && is_string($givennames))
) return $value; else return false;
$empty = (empty($surname) || empty($givennames));
$notstrings = (!is_string($surname) || !is_string($givennames));
if ($empty || $notstrings) {
return false;
} else {
return $value;
}
}
$var = filter_var('Doe, Jane Sue', FILTER_CALLBACK, array('options' => 'foo'));
?>