我正在预约预约项目。从时间表开始使用开始时间和结束时间。我想每天制作如下所示的时间段,以避免预订时段。
# Variant with ascending ordering
library(data.table)
dt <- data.table(df)
dt[, .( val
, num = rank(val))
, by = list(cat)][order(cat, num),]
cat val num
1: aaa 0.05638315 1
2: aaa 0.25767250 2
3: aaa 0.30776611 3
4: aaa 0.46854928 4
5: aaa 0.55232243 5
6: bbb 0.17026205 1
7: bbb 0.37032054 2
8: bbb 0.48377074 3
9: bbb 0.54655860 4
10: bbb 0.81240262 5
11: ccc 0.28035384 1
12: ccc 0.39848790 2
13: ccc 0.62499648 3
14: ccc 0.76255108 4
# Variant with descending ordering
dt[, .( val
, num = rank(-val))
, by = list(cat)][order(cat, num),]
我使用此链接Partion 20 min slot of time in php from start and end time
尝试了以下代码"availableSlots": [
{
"start": "10:30",
"stop": "11:00"
},
{
"start": "11:00",
"stop": "11:30"
},
{
"start": "11:30",
"stop": "12:00"
},
{
"start": "12:00",
"stop": "12:30"
},
{
"start": "12:30",
"stop": "13:00"
},
{
"start": "13:00",
"stop": "13:30"
},
{
"start": "13:30",
"stop": "14:00"
},
{
"start": "14:00",
"stop": "14:30"
},
{
"start": "14:30",
"stop": "15:00"
},
{
"start": "15:00",
"stop": "15:30"
}]
当我预订了一些插槽时,上面的代码工作正常。 但是当$ bookedSlots为空时意味着没有预定的插槽,我必须显示所有可用的插槽,但它返回空数组。 有人可以帮忙吗?
答案 0 :(得分:0)
$i++
循环中的for()
在哪里?
// this
for ($i = $start; $i <= $end;) { //for loop
// should be this
for ($i = $start; $i <= $end; $i++) { //for loop