|
Posted by Steve on 04/20/07 05:36
| goal: validate an array of data using array_walk and print the results.
well hell. if that is truly the goal, then this is completely appropriate:
<?
$numbers = array(1, 56, 999, 1000, 28, 65);
function validateInput(&$value)
{
$maxValue = 999;
if ($value <= $maxValue) return;
echo 'Element ' .
$key .
' must be a whole number ' .
'between 0 and ' .
$maxValue .
'.';
}
array_walk($numbers, 'validateInput');
?>
but using $errors (as in the original answer) later in the code would be
lost.
:)
[Back to original message]
|