Archive for December, 2012

PHP Number format in middle of string

Thursday, December 6th, 2012

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