0

I Need to format a number for a Mysqli query.

it can be [1] [1.1] [1.111111..] and has to be the format [1.10] later.

i tried to use number_format($number, 2, ',', ' '); wich actually works.

But the Problem is, this rounds up. eg. for 1.555555555, it does 1.56 as result. is there a way to just format it to 2 decimals without rounding? like just delete everything afert the 2nd decimal?

1 Answer 1

5

Do you mean the following?

<?php
 $number = 1.956;
 $number_floored = floor($number*100)/100;
 echo $number_floored; //1.95
?>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.