假设有字符串$a = '8元';$b = '8.3'; 怎么统一变为$c = '8.0元'?
$b = '8.3';echo number_format(floor($b),1).' 元';
$b = '8.3';echo number_format(floor($b),1).' 元';
$a = '8元';echo preg_replace_callback('#(\d+)元#',create_function('$m','return number_format(floor($m[1]),1)." 元";'),$a);
$a = '8元';$b = '8.3';echo intval($a) . '.0';echo intval($b) . '.0';
$c = sprintf('%.1f',intval($a));
$a =8.3;
//第一种
$c1 = number_format(floor($a),1);
echo $c1 ."
";
//第二种
$c2 =sprintf( "%.1f ",floor($a));
echo $c2 ."
";
$c3 =printf( "%.1f ",floor($a));
echo $c3 ."
";