I’m trying to read some images from 2 folders (images and thumbnails).
<?php
$dir_thumb = "load/thumbnails/";
$thumb = glob($dir_thumb."*.jpg");
foreach($thumb as $newThumb) {
echo '<ul><li data-type="media" data-url="load/images/a1.jpg"></li><li data-thumbnail-path="'.$newThumb.'"></li></ul>';
} ?>
This works, but I want the data-url
link also dynamically loaded in.
I tried the followings, but that failed:
<?php
$dir_images = "load/images/";
$images = glob($dir_images."*.jpg");
$dir_thumb = "load/thumbnails/";
$thumb = glob($dir_thumb."*.jpg");
foreach($images as $newImages) {
echo '<ul><li data-type="media" data-url="'.$newImages.'"></li>';
}
foreach($thumb as $newThumb) {
echo '<li data-thumbnail-path="'.$newThumb.'"></li></ul>';
}
?>
Also I tried to put the first foreach
in the other foreach
, but that works partly.
Only the first foreach
seam to be loading in the images.
What do I do wrong here?