diff --git a/reference/filter/functions/filter-var.xml b/reference/filter/functions/filter-var.xml index ae515048e7..12cfdee46e 100644 --- a/reference/filter/functions/filter-var.xml +++ b/reference/filter/functions/filter-var.xml @@ -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')); ?> ]]>