PHP Number format in middle of string

Here is a quick and simple way to format numbers that are inline in a text string. It just looks better.

function betterTxt($txt){
$txt = explode(” “,$txt);
$ret = “”;
foreach( $txt as $t ){
$ret .= ( is_numeric($t) ? number_format( $t ) : $t );
}
return $ret;
}

that simple

Tags: ,

Comments are closed.