简体   繁体   English

获取高度和宽度属性与PHP?

[英]Get height and Width attribute with php?

<img src="......" width="....." height="...."/>

如果我有生成上述代码的函数,如何使用php获取width和height属性?

You can use getimagesize() 您可以使用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. 然后让它们分别排列。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM