Skip to content
PHP Logo

How can one access the values in the getImageSize array in PHP?

To access the values in the getImageSize array in PHP, you can use list() to assign the array values to individual variables. This allows you to easily access and use the width and height values stored in the array.

php
// Get image size
$imageSize = getimagesize('image.jpg');

// Access width and height values
list($width, $height) = $imageSize;

// Output width and height
echo "Width: $width, Height: $height";