I have a php script which displays all photos from folder dir and I need to include an html tag that applies given data-parameters. the php code is:
?php
$directory = "images/*/";
$images = glob("" . $directory . "*.png" );
$imgs = '';
foreach($images as $image){ $imgs[] = "$image"; }
shuffle($imgs);
$imgs = array_slice($imgs, 0, 20);
foreach ($imgs as $img) {
echo "<img src='$img' /> ";
}
?>
and I need to put this in html tag as img src:
<img src="" title="Ring" data-parameters='{"zChangeable": true, "x": 215, "y": 200, "colors": "#000000", "removable": true, "draggable": true, "rotatable": true, "resizable": true, "price": 10, "boundingBox": "Base", "autoCenter": true}' />
I tried instead of echo " create new var with value $img and use but that gives me me only one image
print_r( $images ); die();
afterglob
line ) Because your code to output img is correct, so I bet that the problem is in theglob()
command... – fusion3k$imgs = array();
rather than declaring it as a string. If its gonna be an array then its declaration should show that. :) – Simon Willan