所以我试图创建一个占用金额,百分比(十进制)和时间的函数,并返回一个带有金额的double。
我期望的结果如下:
<div class="ytsound-cover" ng-class="{'ytsound-cover-lower': hover, 'ytsound-cover': !hover}" ng-mouseenter="hover = true" ng-mouseleave="hover = false" id="cover">
</div>
<div id="ytsound">
<iframe width="300" height="250" src="//www.youtube.com/embed/TbsBEb1ZxWA?autoplay=1&loop=1&playlist=TbsBEb1ZxWA&showinfo=0&start=65" frameborder="0" allowfullscreen></iframe>
</div>
所以..
.ytsound-cover{
background: #fff;
height: 250px;
position: absolute;
width: 301px;
}
.ytsound-cover-lower {
background: #fff;
height: 205px;
position: absolute;
width: 301px;
}
我知道这是一个逻辑错误,但我已经太多了,我现在似乎不再工作了:( 你能帮帮我吗?
谢谢!
答案 0 :(得分:4)
您可以使用pow功能实现它
function elevateToPercentage($amount, $percentage, $times) {
$multiple = pow($percentage, $times);
return number_format($amount*$multiple) ;
}
$amount = 10000;
$percentage = 1.1;
$times = 1;
echo elevateToPercentage($amount, $percentage, $times);
Out put:
$times = 1; 11,000
$times = 2; 12,100
$times = 4; 14,641
答案 1 :(得分:2)
怎么样:
function elevateToPercentage($amount, $percentage, $times) {
if ($times == 1){
return $amount * $percentage;
}else{
return $percentage * elevateToPercentage($amount, $percentage, $times -1);
}
}