-3

I am facing the below issue with my php code.

$value = 28.835223;
$newValue = floor($value);

When I echo $newValue, it will show 28. But when I use $newValue for a new calculation, the value is 28.835223.

How can I use the new floor value "28" in my calculations?

j08691
  • 204,283
  • 31
  • 260
  • 272
Jo'
  • 1
  • 2
  • No it should not returned to its float value, must be there something wrong with your calculations, please share the full code related to this issue – Mohammad Feb 17 '17 at 14:18
  • Thank you Mohammad, actually floor works fine, it was a mistake within the calculation. – Jo' Feb 17 '17 at 15:03
  • Your code should work. Look at your code, you must have used `$value` instead of your `$newValue`. – qdruault Feb 17 '17 at 14:26

1 Answers1

1

Try below code

$value = 28.835223;
$newValue = (int) $value;
echo $newValue;
Pramod Patil
  • 2,704
  • 2
  • 14
  • 20