Seems simple but can't figure this out:
$goal = 10.000;
$actual = 55.32;
$percentChange = number_format(( $actual / $goal) * 100, 2);
echo $percentChange;
OUTPUT
553.20
WANTED OUTPUT
0.5532
The problem occurs only when output is less than 1 0.XXXX code is working fine from 1 above.
Remove the dot in $goal
variable as is taking it as 10 with 4 decimals
Change this:
$goal = 10.000;
$actual = 55.32;
$percentChange = number_format(( $actual / $goal) * 100, 2);
echo $percentChange;
To this:
$goal = 10000;
$actual = 55.32;
$percentChange = number_format(( $actual / $goal) * 100, 4);
echo $percentChange;