我正在尝试解决一个问题,我有这样的一系列日子
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/flipclock/0.7.8/flipclock.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/flipclock/0.7.8/flipclock.min.js"></script>
<div class="clock"></div>
我想在一个循环中将它们打印66次,每次到星期五时,阵列都会重置并自动打印星期一。我试过了:
$days = array ('Monday','Tuesday ','Wednesday ','Thursday ','friday');
答案 0 :(得分:1)
val jsonResponse = ApiClientLive().get("events/" + id.toString() + ".json")
val event = GsonBuilder().create().fromJson(jsonResponse, Event::class.java) // <-- Crashes here
Collections.sort(event.courses!!) { course1, course2 -> course1.name!!.compareTo(course2.name!!, ignoreCase = true) }
答案 1 :(得分:1)
<?php
$days = array ('Monday','Tuesday ','Wednesday ','Thursday ','friday');
for($i=0 ; $i<66; $i++ ){
foreach ($days as $row){
echo $row;
echo '</br>';
}
}
你只需要2个循环。 1表示日期数组,1表示您想要重复的时间。
答案 2 :(得分:1)
有两个计数器变量,并执行类似的操作。
$a = 0;
$days = array('Monday','Tuesday ','Wednesday ','Thursday ','friday');
for ($i = 0; $i < 65; $i++) {
print($days[$a]);
$a++;
if ($a == sizeof($days)) {
$a = 0;
}
}
答案 3 :(得分:1)
这是使用the extensive range of Iterator classes available in the SPL
的绝佳机会<?php
$days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'];
$infinite = new InfiniteIterator(new ArrayIterator($days));
foreach ( new LimitIterator($infinite, 0, 66) as $value ) {
echo $value, PHP_EOL;
}