- preg_match: documentation ( source)
- sprintf: documentation ( source)
<?php
$exp = '/^[a-z]{2}|all$/';
$tests = array('fr', 'french', 'FR', 'all', 'ALL');
foreach ($tests as $test) {
echo sprintf("%-10s : %s\n", $test, preg_match($exp, $test) ? "OK" : "ERROR");
}