mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Rewrote callback filter example. Closes bug #60769.
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@322551 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
4f2bd63271
commit
5b22a7460f
1 changed files with 8 additions and 6 deletions
|
@ -69,15 +69,17 @@ $var = filter_var('oops', FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
|
|||
$var = filter_var('oops', FILTER_VALIDATE_BOOLEAN,
|
||||
array('flags' => FILTER_NULL_ON_FAILURE));
|
||||
|
||||
// callback filter
|
||||
// callback validate filter
|
||||
function foo($value)
|
||||
{
|
||||
$ret = new stdClass;
|
||||
$ret->value = filter_var($value, FILTER_VALIDATE_BOOLEAN,
|
||||
array('flags' => FILTER_NULL_ON_FAILURE));
|
||||
return $ret;
|
||||
// Expected format: Surname, GivenNames
|
||||
list($surname, $givennames) = explode(", ", $value, 2);
|
||||
if(
|
||||
!(empty($surname) || empty($givennames))
|
||||
&& (is_string($surname) && is_string($givennames))
|
||||
) return $value; else return false;
|
||||
}
|
||||
$var = filter_var('yes', FILTER_CALLBACK, array('options' => 'foo'));
|
||||
$var = filter_var('Doe, Jane Sue', FILTER_CALLBACK, array('options' => 'foo'));
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
|
Loading…
Reference in a new issue