我有以下 CSV
Date,Event,Description
24/01/2010,Football,Football practice for all Years.
24/01/2010,Cricket,Cricket Practice for all Years.
25/01/2010,Piano Lessons,Paino lessons for Year 10.
Date, Event and Description
是我想要过滤的标题。
我正在获取今天的日期,然后我想读取 CSV 并输出与今天的日期匹配的事件。我也想了解明天的活动。
如上所述,您确实想使用fgetcsv()
。您可以这样做(未经测试):
<?php
if (($handle = fopen("test.csv", "r")) !== FALSE) {
$today = strtotime("today");
$tomorrow = strtotime("tomorrow");
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
if (strtotime($data[0]) == $today || strtotime($data[0]) == $tomorrow)) {
echo 'Category: ' . $data[1] . "<br>\n";
echo 'Event: ' . $data[0] . "<br><br>\n\n";
}
}
fclose($handle);
}
?>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)