开发者

Get height and Width attribute with php?

开发者 https://www.devze.com 2023-04-09 13:16 出处:网络
开发者_如何学编程<img src=\"......\" width=\".....\" height=\"....\"/> If I have a function generating the above code, how can I get the width and height attributes with php?You can use getima
开发者_如何学编程<img src="......" width="....." height="...."/>

If I have a function generating the above code, how can I get the width and height attributes with php?


You can use getimagesize()

<?php    
     list($width, $height, $type, $attr) = getimagesize("http://example.com/image.gif");
?>
<img src="..." width="<?= $width ?> height="<?= $height ?>" />


Do you mean something like this ?

So you would need to use

preg_match_all('/(alt|title|src)=("[^"]*")/i',$img_tag, $img[$img_tag]);

And then foreach them to array.

0

精彩评论

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