Function Percentage in PHP

2

How to do a percentage function. In that it calculates the td or the equal table of Excel to give the percentage.

I want to calculate the percentage of a value in PHP, for example 10% of 100, type Excel DADOSx100=% and calculate the tables in PDO.

    
asked by anonymous 29.11.2015 / 02:50

2 answers

1
$valor = 100; // valor total
$porcent = 50;
$totalporcent = 100;
$total = $porcent / $totalporcent;

$resultado = $total * $valor;

echo $porcent . "% de " . $totalporcent ." é: " .
$resultado;

//é igual ao de cima, mas achei melhor explicar um pouco melhor kkk
    
29.11.2015 / 16:35
6

Considering what you said in the comment of your question would look like this:

$valor = 100; // valor total
$porcent = 10 / 100; // 10%

$resultado = $porcent * $valor;

echo "10% de 100 é: " .
$resultado;
    
29.11.2015 / 03:51