$num + 0
does the trick.
echo 125.00 + 0; // 125
echo '125.00' + 0; // 125
echo 966.70 + 0; // 966.7
Internally, this is equivalent to casting to float with (float)$num
or floatval($num)
but I find it simpler.
More Related Contents:
- Increment number php every next number
- php , I want to build array from 12 values each value has max number of 2048
- Show a number to two decimal places
- Formatting a number with leading zeros in PHP [duplicate]
- Why does PHP consider 0 to be equal to a string?
- How to mathematically evaluate a string like “2-1” to produce “1”?
- Is there an easy way to convert a number to a word in PHP?
- Print numeric values to two decimal places
- Why is PHP printing my number in scientific notation, when I specified it as .000021?
- Display numbers with ordinal suffix in PHP
- Test if number is odd or even
- Converting words to numbers in PHP
- PHP How do I round down to two decimal places? [duplicate]
- What is the best way to validate a credit card in PHP?
- Strange behaviour with numbers that have a leading zero [duplicate]
- PHP: Express Number in Words [duplicate]
- Round to max thousand, hundred etc in PHP
- Convert exponential number to decimal in php
- PHP: get number of decimal digits
- PHP: Create an array for a range
- PHP prepend leading zero before single digit number, on-the-fly [duplicate]
- Max file number can php upload at same time
- PHP convert decimal into fraction and back?
- php random x digit number
- PHP remove commas from numeric strings
- php: number only hash?
- Incrementing numbers starting from 0000 in php
- Convert number into xx.xx million format? [closed]
- PHP DateTime supported formats
- Is it possible to capture search term from Google search?