All pastes #189516 Raw Edit

Miscellany

public text v1 · immutable
·published 2006-10-03 04:07 UTC
rendered paste body
	function is_email($val)
	{
		if ( !preg_match("/([a-zA-Z0-9\-_\^~]+)@([a-zA-Z0-9\-_\^~]+)\.([a-zA-Z]{2,3}$|[a-zA-Z]{2,3}\.[a-zA-Z]{2,3}$)/i", $val) )
		{
			if ( preg_match("/([a-zA-Z0-9\-_\^~]+)@([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$)/i", $val) )
			{
				$oct = explode(".", $val);
				
				$len = count($oct);
				for ($i = 0; $i < $len; $i++)
				{
					$int = (int)$oct[$i];
					
					if ($int > 255 || $int <= 0) return( false );
				}
			}
		}
		return( true );
	}