拿到图片的长宽

 

 

function get_pic_size($pic_url){
    $size = getimagesize ($pic_url);
    $a=explode(" ",$size[3]);
    foreach ($a as $k=>$v){
        $b=explode("=",$v);
        $b[1]=str_replace('"','', $b[1]);
        $a[$b[0]]=$b[1];
    }
    unset($a[0]);
    unset($a[1]);
    return $a;
}

 

 

返回值

 

array(2) {
  ["width"]=>
  string(5) ""430""
  ["height"]=>
  string(5) ""430""
}

 

单位:px

 

posted @ 2019-10-12 17:30  心雨星空  阅读(120)  评论(0)    收藏  举报