Search code examples
phpdoubletypecasting-operator

how to convert string to double in php without using doubleval function?


I have a string value $a=10. I have to convert to double value before storing. how to convert string to double in php.

I tried adding 0.00 to the $a. i.e $a= $a+0.00; But it doesn't work


Solution

  • Just use this

       $a = 10;
       echo number_format($a, 2);