开发者

Getting link content size

I have a page with more than 100 links(xml files). With some p开发者_如何学编程rework I'm getting the links and saving all the data to a server, but I don't want to save that files which size are smaller than xxKb. How could I get the size?


foreach($links as $link) {
   $data = file_get_contents($link);
   if (strlen($data) >= $min_size) {
      file_put_contents($data, 'some file name on your server');
   }
}


You could just use the filesize method:

foreach($links as $link){
    if(filesize($link) > xx){
        ...
    }
}


Try filesize function. From the Manual:

int filesize ( string $filename )

Gets the size for the given file.

Parameters filename - Path to the file.

Return Values

Returns the size of the file in bytes, or FALSE (and generates an error of level E_WARNING) in case of an error.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜