I'm trying to echo images using php, my images are stored in array , so I can't skip empty value, my php code is
$images = 'imgs/001.jpg,imgs/001.gif,imgs/002.png,imgs/003.jpg,imgs/004.jpg,
imgs/005.jpg,imgs/006.png,imgs/007.png,';
$expl = explode (',', $images);
foreach ($expl as $path){
if (!empty($path) || getimagesize($path)!== false){
$type = pathinfo($path, PATHINFO_EXTENSION);
$data = file_get_contents($path);
$base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);
echo '<img src="'.$base64.'" width="300" height="300">' . '<br>';
var_dump (getimagesize($path));
}
}
because of the last comma in my $images I get error
Warning: getimagesize(): Filename cannot be empty in I:\zzerver\Uwamp -port 84\uw-cms-p8585\www\test\php\images\dataimage-explode1-1.php on line 9
I tried : if (!empty($path) || getimagesize($path)!== false)
but seems that not working, I get the same error