I am trying to convert a cricket over ie 6to show 0.6and 12to show 1.6. I earned everything except the last part, where it returns the full number.
My code is:
foreach($numberofballs as $x){
$first = floor($x / 6);
$last = $x - ($first * 6);
echo $first.'.'.$last;
}
Allows you to designate an array for testing, suppose the array below needs to be converted for this loop
$numberofballs = array(1,2,3,4,5,6);
foreach($numberofballs as $x){
$first = floor($x / 6);
$last = $x - ($first * 6);
echo $first.'.'.$last;
}
/* notes
for 1 it does it right = 0.1
for 2 it does it right = 0.2
for 3 it does it right = 0.3
for 4 it does it right = 0.4
for 5 it does it right = 0.5
how its supposed to work for 6:
for 6 I do not want to get = 1 I would like to get 0.6 and no there is never 0.7
/ end notes */
I am not saying that the code above is incorrect, I just want to get the correct value.
Genus source
share