Input: any integerOutput: that integer in number format (commas) with a leading a or an as appropriate with the rules of EnglishAfter a bit of groping around I hacked out the following PHP function, and am looking for any advice on code structure and optimization. Thank you!function prefixAAnToNumber($num) {    $prefixAn = array(8, 11, 18, '8', '11', '18');    $verAn = 'an ' . number_format($num);    $verA = 'a ' . number_format($num);    if (in_array($num,$prefixAn)) {        return $verAn;    } else if (strlen($num) > 1) {        $numComma = number_format($num);        if (substr($numComma,0,1) == '8') {            return $verAn;        } else if (in_array(substr($numComma,0,2), $prefixAn) && substr($numComma,2,1) == ',') {            return $verAn;        } else {            return $verA;        }    } else {        return $verA;    }}Example usage:$num = 11;for ($i = 0; $i < 10; ++$i) {    echo '<p>'.$num.' -> ';    echo prefixAAnToNumber($num);    echo ' kg shipment</p>';    $num = $num * 10;}Output:11 -> an 11 kg shipment110 -> a 110 kg shipment1100 -> a 1,100 kg shipment11000 -> an 11,000 kg shipment110000 -> a 110,000 kg shipment1100000 -> a 1,100,000 kg shipment11000000 -> an 11,000,000 kg shipment110000000 -> a 110,000,000 kg shipment1100000000 -> a 1,100,000,000 kg shipment11000000000 -> an 11,000,000,000 kg shipment
function to append a or an to the front of a number as appropriate
php