PHP Read CSV and filter by date

前端 未结 6 1955
再見小時候
再見小時候 2021-01-24 08:12

I have the following CSV

Date,Event,Description
24/01/2010,Football,Football practice for all Years.
24/01/2010,Cricket,Cricket Practice for all Years.
25/01/201         


        
6条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-24 08:27

    one way

    $today=date('d/m/Y');
    $tomorrow = mktime(0,0,0,date("m"),date("d")+1,date("Y"));
    $tmr = date("d/m/Y", $tomorrow)."\n";
    $handle = fopen("file", "r");
    fgets($handle,2048);
    while (($data = fgetcsv($handle, 2048, ",")) !== FALSE) {
        $date=explode("/",$data[0]);
        if ( $today == $data[0] || $tmr == $data[0]){
            $j = implode(",", $data);
            print $j."\n";
        }
    }
    fclose($handle);
    

提交回复
热议问题