mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
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:
parent
8a3d8d125a
commit
b3445eefdd
1 changed files with 8 additions and 4 deletions
|
@ -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'));
|
||||
?>
|
||||
|
|
Loading…
Reference in a new issue