现在还不确定这个答案有多重要,但它可能会在将来对某人有所帮助。
建议切换$entries
和$entry
. 你用的东西很让人困惑$entries
对于单数输入和$entry
用于条目数组。
定义您想要的输出。你想得到一个数组,但你正在用每个循环重写你的值-这就是为什么最后一个循环仍然存在-就像你在重新粉刷房子,想知道为什么只能看到顶部的颜色。。。
我想说你想对$calendar_data
数组和an$outputx
输出:
$calendar_data = array();
$outputx = "";
$entries = GFAPI::get_entries($form_id, $search_criteria, $sorting, $paging, $total_count);
foreach ($entries as $entry) {
$idx = rgar($entry, \'id\');
$calendar_data[$idx]["fname"] = rgar($entry, \'13.3\');
$calendar_data[$idx]["lname"] = rgar($entry, \'13.6\');
$calendar_data[$idx]["pto_start"] = rgar($entry, \'1\');
$calendar_data[$idx]["pto_end"] = rgar($entry, \'3\');
$calendar_data[$idx]["e_location"] = rgar($entry, \'16\');
$calendar_data[$idx]["pto_approval"] = rgar($entry, \'15\');
$supervisor_location = um_user(\'employee_location\');
if (($supervisor_location === \'Elk City, OK\') && ($e_location === \'Elk City, OK\' )) {
if ($pto_start != $this->currentDate) {
$outputx .= \'<div id="\' . $this->currentDate . \'" class="day \' . ($cellNumber % 7 == 1 ? \' start \' : ($cellNumber % 7 == 0 ? \' end \' : \' \')) .
($cellContent == null ? \'mask\' : \'\') . \'">\' . $cellContent . \'</div>\';
} elseif ($pto_start == $this->currentDate) {
$outputx .= \'<div id="\' . $this->currentDate . \'" class="day has-pto \' . ($cellNumber % 7 == 1 ? \' start \' : ($cellNumber % 7 == 0 ? \' end \' : \' \')) .
($cellContent == null ? \'mask\' : \'\') . \'">\' . $cellContent . \'<div class="inner-pto-cal \' . lcfirst($pto_approval) . \'">\' . $fname . \' \' . $lname . \'</div></div>\';
}
}
}