<?php
$num = 1234.5678;
$str = "decimals";
echo sprintf("%.2f", $num).'<br />';
echo sprintf("%2$.2f", $str, $num);
//1234.57<br />1234.57
php sprintf
最新推荐文章于 2022-03-11 21:00:59 发布
<?php
$num = 1234.5678;
$str = "decimals";
echo sprintf("%.2f", $num).'<br />';
echo sprintf("%2$.2f", $str, $num);
//1234.57<br />1234.57