Answer the question
In order to leave comments, you need to log in
How, when the end of the array is reached, continue to bypass it from the beginning?
Hello!
There is such an array:
$arrya = array(
array(),
array(),
array(),
array(),
// ещё сколько-то раз это же
array(),
);
// Число элементов в массиве
$count_array = count($array);
// Выводить элементов на страницу
$count_str = 5;
if($count_array > 0) {
$html = '';
// Текущий день месяца числом
$j = date('j');
// Конечная позиция
$end_key = $j * $count_str;
// Начальная позиция
$start_key = $end_key - $count_str;
for($i = $start_key; $i < $end_key; $i++) {
if(array_key_exists($i, $array)) {
$value = $array[$i];
$html .= $i.' => TRUE <br/>';
}
else {
$html .= $i.' => FALSE <br/>';
}
}
echo $html;
}
Answer the question
In order to leave comments, you need to log in
Your problem is that your offset is not attached to anything. considering that it will be different at the beginning of each month, it is not surprising that you are confused.
If I were you, I would look at the GregorianToJD() function.
Zahardkodil in the script the value returned to it on the day the impressions start
And then calculate the offset from the difference with the current value.
The % operator might come in handy for this.
Well, add array_slice, for beauty
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question