Skip to content
Advertisement

How do I truncate a decimal in PHP?

I know of the PHP function floor() but that doesn’t work how I want it to in negative numbers.

This is how floor works

JavaScript

This is what I WANT

JavaScript

Is there a PHP function that will return -1234?

I know I could do this but I’m hoping for a single built-in function

JavaScript

Advertisement

Answer

Yes intval

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement