## Question:

I have a variable called `$poits`

which has numerical values, of that variable I need to show its values in percentage between `1`

to `100%`

, which the condition to reach `100%`

that variable must have a value of `1000`

(thousand) points, to reach `100%`

.

From that same variable I need another option to be able to move to dollars, the condition is that if that variable has the value of `1000`

(thousand), it prints a profit of `$5.00`

dollars, but if it has another value that shows how much it is generating, for say if it only has a value of `30`

, this shows in dollars the percentage I imagine by saying `$0.00012`

for `$5.00`

.

My idea is to show a graph with the percentages, and at the same time show you your earnings according to the graph.

## Answer:

Try processing your values using a simple rule of three and save your calculations in an associative array:

```
/* Regla de tres simple para abmso cálculos
* 1000 = $5 = 100%
* 30 = $x = n%
*/
//base
$base = 1000;
//ganancia maxima
$max_ganancia = 5;
//valor
$points = 1000;
// cálculo de porcentaje y ganancia
$porcentaje = $points * 100 / $base;
$ganancia = $points * $max_ganancia / $base;
//poniendo dos decimales a la ganancia
$ganancia = number_format( $ganancia, 2 );
echo $points." => ".$porcentaje."% - $".$ganancia;
```

Here the **demo**