<?php echo $i['sellingStatus'][0]['currentPrice'][0]['__value__']; ?>
How can I multiply% by% by 2 and then add 60% to the total value?
Example:
Valor = 10
Multiplica por 2 = 20
Acrescenta 60% = 20 * 60% = 12
Total = 20 + 12 = 32.
<?php echo $i['sellingStatus'][0]['currentPrice'][0]['__value__']; ?>
How can I multiply% by% by 2 and then add 60% to the total value?
Example:
Valor = 10
Multiplica por 2 = 20
Acrescenta 60% = 20 * 60% = 12
Total = 20 + 12 = 32.
<?php echo $i['sellingStatus'][0]['currentPrice'][0]['__value__'] * 3.2 ;>
Calculating an increase of 60% is the same as multiplying by 1.6. After all 100% = 1, therefore 60% = 0.6. As we want to add, we want 100% + 60%, ie multiplying by (1 + 0.6) = > (1.6)
If you want to multiply by 2 and then add 60%, it would be equivalent to
valor * 2 * 1.6
Simplifying
valor * 3.2
If you want to use the formula in several items with different percentages, then the thing changes. You could use a function for this:
$indice = 2; // Acrescentado com base no comment, que vai ser o índice do dólar.
echo acrescimo( $i['sellingStatus'][0]['currentPrice'][0]['__value__'] * $indice, 60 );
function acrescimo( $valor, $porcentagem) {
return $valor * ( 1 + $porcentagem/100 );
}
Try this way, following the formula to find out the percentage is: (numero1/100) * a porcentagem que você quer descobrir
valor = 10;
multiplicado = 10*2;
porcentagem = (multiplicado/100)*60;
total = multiplicado+porcentagem;
I will only complement the previous answers, since both are very accurate:
<?php
function acrescenta($valor, $percentual){
return($valor * ( 1 + ($percentual / 100)));
}
?>
You use this (assuming the original value is 50):
<?php
$total = $total * 2;
$total = acrescenta(50, 60);
?>