嗨,我知道有这么多问题,但我的情况不同。我是PHP的新手,我试图在PHP中切片,结果是mysqli_fetch_array()
结果来自后端:
Array (
[0] => Array ([0] => 1 [dt_id] => 1 [1] => 09:00 AM [dt_time] => 09:00 AM)
[1] => Array ([0] => 2 [dt_id] => 2 [1] => 09:15 AM [dt_time] => 09:15 AM)
[2] => Array ([0] => 3 [dt_id] => 3 [1] => 09:30 AM [dt_time] => 09:30 AM)
)
for ($row = 0; $row < $recordscoun; $row++)
{
for ($col = 0; $col < count($records[$row]); $col++)
{
if('09:15 AM' == $records[$row][$col]) {
print_r(array_slice ($records, $row));
}
}
}
它没有对数组进行切片,我搜索了很多但没有找到解决方案。
答案 0 :(得分:0)
您最好在查询中执行此操作,但对于PHP array_slice
而言,这不是您想要的。比较时间过滤数组:
$records = array_filter($records, function($v) {
return strtotime($v['dt_time']) >= strtotime('9:15 AM');
});