Value rounding up php does not work [closed]

-2

I want to transform the returned value of a sum, formatted without periods (.) or comma (,)

$valor comes from a POST , then a sum is added:

echo $porcent * ceil($valor);

The above code returns me the following value 99.99 or greater than 999.99 I believe, hence I want this value to return 9999 without a semicolon. I'm drumming the coconut and I do not get results.

Follow the code.

<?php $valor = $_POST['valor']; $porcent = $_POST['porcent'] / 100; ?>
</head>
<body>
    <span style="width:40px" class="text-muted"><?php echo $porcent * ceil($valor); ?></span>
    
asked by anonymous 31.08.2018 / 03:08

1 answer

2

First you must do the calculation and then round the value:

<?php
   $valor = 1863;
   $porcent = 20 / 100;
   $resultado = $porcent * $valor;
?>
<span style="width:40px" class="text-muted"><?php echo ceil($resultado);?></span>

functional example in ideone

    
31.08.2018 / 05:04