How to add percentage to a value in PHP? [duplicate]

-2

I'm trying to add a percentage of the value to it, but I could not do it.

   <?php

   $data = json_decode(file_get_contents("https://broker.negociecoins.com.br/api/v3/btcbrl/ticker"));
  echo "<pre>";
  print_r($data->sell);
  echo "</pre>"; ?>

I have this JSON which returns me a value and I would like to add for example + 30% in that value before displaying it, but anyway I tried does not work, does anyone have an idea?

    
asked by anonymous 27.09.2018 / 15:32

2 answers

1

You can do this:

$valor *= (1+$percentual/100);

$data->sell *= (1+30/100); //30% de acréscimo

Or this way.

$valor_acrescido = (($data->sell*30)/100)+$data->sell;
    
27.09.2018 / 15:34
-1

Percentage

$valor_acrescido = (($data->sell*30)/100)+$data->sell;
    
27.09.2018 / 15:35