I have this function which declares variables:
function imageSize($name, $nr, $category){
$path = 'ad_images/'.$category.'/'.$name.'.jpg';
$path_thumb = 'ad_images/'.$category.'/thumbs/'.$name.'.jpg';
list($width, $height) = getimagesize($path);
list($thumb_width, $thumb_height) = getimagesize($path_thumb);
${'thumb_image_' . $nr . '_width'} = $thumb_width;
${'thumb_image_' . $nr . '_height'} = $thumb_height;
${'image_' . $nr . '_width'} = $width;
${'image_' . $nr . '_height'} = $height;
}
When I echo this:
echo $image_1_width
It works fine, but if I do it OUTSIDE the function it wont recognize the variable, how can I make them ‘global’ somehow?
Thanks
I would strongly advise NOT using global.
What will probably be best is for you to return from the function:
$myImage = imageSize($name, $nr, $category);then you access each var:
etc.