convert string decimal to number decimal php forced 2 decimal places code example
Example 1: fix to 2 decimal places php
return number_format((float)$number, 2, '.', '');
Example 2: string to decimal php
$num = (double) "10.12";
return number_format((float)$number, 2, '.', '');
$num = (double) "10.12";