这是我编写的 php,它与一些 wordpress 功能略有混合。
但是,我希望将所有值四舍五入到小数点后一位,但我无法弄清楚如何做到这一点——下面的 php 非常基础——但我无法计算出小数点的下一步。
<?php
$one_decimal_place = number_format(2.10, 1);
// AVERAGE DRINK COSTS
$li2 = get_field('average_drinks_spenditure_per_night');
$li3 = ($li2 * 28) * 2.1;
$li4 = $li3 * 3;
// HOUSING COSTS
$li22 = (get_field('average_housing_costs_per_week') * 4 );
$li33 = $li22 * 12;
$li44 = $li33 * 3;
// SHOPPING COSTS
$li222 = (get_field('average_shopping_trip_price') * 2.25 );
$li333 = $li222 * 12;
$li444 = $li333 * 3;
// TUITION FEES
$tuitionClass = (get_field('tuition_fees') /28 );
$tuitionTotal = (get_field('tuition_fees') * 3 );
// PHP TCE
$totalcost2 = $li444 + $tuitionTotal;
$totalcost3 = $li4 + $li44;
$totalcost = $totalcost2 + $totalcost3;
?>