Get the last modified date of a remote file

前端 未结 8 2125
难免孤独
难免孤独 2020-11-29 02:45

I would like to get the last modified date of a remote file by means of curl. Does anyone know how to do that?

8条回答
  •  清歌不尽
    2020-11-29 03:01

    Sometimes header come with different upper lower case, this should help:

    function remoteFileData($f) {
        $h = get_headers($f, 1);
        if (stristr($h[0], '200')) {
            foreach($h as $k=>$v) {
                if(strtolower(trim($k))=="last-modified") return $v;
            }
        }
    }
    

提交回复
热议问题