<?php

// There will of course be fallacies in these expressions

function validate($str$type)
{
    switch(
$type)
    {
        case 
'email':
            return (
preg_match('/^(.+){1,64}\@(.+){2,255}\.(.+){2,10}$/'$str)) ? true false;
            break;
        case 
'url':
            return (
preg_match('/^(http:\/\/)((.+){3,120})\.([a-zA-Z]+)(\/|)$/'$str)) ? true false;
            break;
        case 
'postcode':
            return (
preg_match('/^([a-zA-Z]{1,2})([0-9]{1,2})(\040|)([0-9]{1})([a-zA-Z]{2})$/'$str)) ? true false;
            break;
    }
}

?>