The active formatter class tries to clean up poorly formatted input and standardize the output. Given an array of various phone numbers and emails, we can print them all in a standard format, or override the format if desired.

Original data is looks like this:

array (
  'tel' => '9995550123',
  'tel2' => '(999)-555-0123',
  'email' => 'mark mark@example.com',
)


Telephone: (999) 555-123

Code for formatting the telephone $t['tel']:

$f = new Cgn_ActiveFormatter($t['tel']);
echo $f;


Telephone #2: 999.555.123

Code for formatting the telephone $t['tel2']:

$f = new Cgn_ActiveFormatter($t['tel2'], '%d.%d.%d');
echo $f;


Email: mark <mark@example.com>

Code for formatting the email $t['email']:

$f = new Cgn_ActiveFormatter($t['email']);
echo $f;