开发者

Getting link content size

开发者 https://www.devze.com 2023-03-28 19:34 出处:网络
I have a page with more than 100 links(xml files). With some p开发者_如何学编程rework I\'m getting the linksand saving all the data to a server, but I don\'t want to save that files which size are sma

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

精彩评论

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