i need help for this task.
i need a for loop who picks the closest duration
sample we have a duration with 120 seconds the 120 seconds are on every calculation divided by 8
so here is an example
120 Duration
Here are the 8 closest values
15
30
45
60
75
90
105
120
How i can realize this i have all tested
<?php
$count = 1;
$duration = 120;
$temp = 0;
for ($x = 1; $x < 120; $x++) {
#$j = $x / 8;
$temp = $x / 8;
echo '<pre>' . ($temp) . '</pre>';
if ($count == 8) {
break;
}
$count++;
}
?>
Your question is quite unclear and the provided code doesn’t go from 1->120 since you break it after 8 iterations.
To get the values 15 30 45 60 75 90 105 120 from the base 120 you would need something like this: