Posts Tagged ‘tips & tricks’

Validate Australian phone numbers in PHP

January 22nd, 2010

Here is a very basic PHP function to validate Australia phone (landline and mobile) numbers.

function validate_phone($number) {
	$number = preg_replace('/[^\d]/', '', $number);
	return preg_match('/^(0(2|3|4|7|8))?\d{8}$/', $number) 
		|| preg_match('/^1(3|8)00\d{6}$/', $number)
		|| preg_match('/^13\d{4}$/', $number);
}

Validating ABNs and ACNs in PHP

August 10th, 2009

Here is a PHP validation class to validate Australian Business Numbers (ABN) and Australian Company Numbers (ACN)

» Read more: Validating ABNs and ACNs in PHP

PHP Camel Case functions

August 10th, 2009

Here are two PHP functions to convert strings between underscore format and camel case.
E.g. from firstName to first_name and vice versa.
» Read more: PHP Camel Case functions