基本上我试图将值相乘。
我下面有一个 ul 正在回显一个数值,:
<ul class="TCE">
<li><span>Average drink cost</span> <?php echo the_field('average_drink_price'); ?></li>
<li><span>Average drinks spenditure per night</span> <?php echo the_field('average_drinks_spenditure_per_night'); ?></li>
<li><span>Average drinks spenditure for the year</span> <!-- JAVA BIT --></li>
<li><span>Average drinks spenditure for 3 years</span> <!-- JAVA BIT --></li>
</ul>
我希望第三个 li 得到第二个 li 的值,然后将该值乘以 28。
然后我希望第四个 li 得到第三个 li 的值并将其乘以 3。
所以它有点像这样:
li-2 x 28 = li-3 li-3 x 3 = li-4
如果这有意义吗?li1 和 li2 的值将通过该 PHP 字段生成,对此有任何帮助,因为我不知道从哪里开始?
更新的 PHP 测试:
<?php
var_dump(the_field('average_drinks_spenditure_per_night'));
$li2 = the_field('average_drinks_spenditure_per_night');
$li3 = ($li2 * 28) * 2.1;
$li4 = $li3 * 3;
?>
<ul class="TCE">
<li><span>Average drink cost</span> <?php echo the_field('average_drink_price'); ?></li>
<li><span>Average drinks spenditure per night</span> <?php echo $li2; ?></li>
<li><span>Average drinks spenditure for the year</span> <?php echo $li3;?><!-- JAVA BIT --></li>
<li><span>Average drinks spenditure for 3 years</span> <?php echo $li4;?><!-- JAVA BIT --></li>
</ul>