It took me about 2 years to come up with the obvious 'arrays of required fields' technique, but ignorance was far from bliss:
$reqFilled = array('name', 'address', 'postcode');
$reqNumeric = array('doornum', 'age');
$reqMinLens('notes' => 30, 'someotherthing' => 800);
// check they've filled what they should have
foreach ($reqFilled as $field)
{
if (empty(trim($_POST[$field])))
{
echo 'You bad man! Fill out '.$field.'<br />';
}
}
// check for numeric fields being done right
foreach ($reqNumeric as $field)
{
if (!is_numeric($_POST[$field]))
{
echo 'How dare you not type in numbers for ', $field, '<br />';
}
}
// check lengths of minimummrah
foreach ($reqMinLens as $field => $length)
{
if (strlen($_POST[$field]) < $length)
{
echo 'Go back and type some more into ', $field, ' before I smack you about summat horrid<br />';
}
}
etc, etc, etc.