You can use this to get rid of the wrong calculation
$ztmmoney = '17,305'; $ztmmoney = intval(preg_replace('/[^\d.]/', '', $ztmmoney));
I am trying to calculate what pace our sales team in on for the month, but when I divide our numbers so far (17,305) by the day of the month (08), I am getting the wrong number (2.125).
I've tried converting the date from a string to a number, but I everything I read says php should know how to handle the numbers when it's a string or number.
$dateday = date('d'); $numberofdays = date('t'); echo $ztmmoney.' total for month<br>'; echo $dateday.' day of the month<br>'; $mavg = $ztmmoney/$dateday; echo $mavg.' daily average<br>'; echo $numberofdays.' days in month<br>'; $pace = $mavg * $numberofdays; echo 'on pace for: '.$pace;
I should see 17,305/8 = 2,163.125
but this is my output:
17,305 total for month
08 day of the month
2.125 daily average
31 days in month
on pace for: 65.875