Hi,
I'm listing a directory & trying to use a foreach loop to empty the list into an array, but keep running into problems "Parse error: syntax error, unexpected T_FOREACH, expecting ')' ".
Can anyone shed some light, please?
I'm listing a directory & trying to use a foreach loop to empty the list into an array, but keep running into problems "Parse error: syntax error, unexpected T_FOREACH, expecting ')' ".
Can anyone shed some light, please?
Code:
$timestorepeat = 5;
//path to directory to scan
$scrolldirectory = "includes/images/Right-Hand-Scroll/";
//get all image files with a .jpg extension.
$scrollimages = glob("" . $scrolldirectory . "*.jpg");
$i = 0;
$items = array(
foreach ($scrollimages as $image){
++i;
$i => array(
'href' => ''.$image.'',
'title' => ''.$image.'',
'src' => ''.$image.'',
'alt' => ''.$image.'',
'border' => '0',
'width' => '110',
'height' => '80'),
}
);
//shuffle the master array randomly
shuffle($items);
$count = 0;
while ($count <=$timestorepeat)
{
//now output them
foreach ($items as $item) {
echo <<<HTML
<tr>
<td class="infoBoxContents" valign="top"></td>
<td class="infoBoxContents"><center>
<a href="{$item['href']}"
title="{$item['title']}" target="_new">
<img src="{$item['src']}"
alt="{$item['alt']}"
border="{$item['border']}"
width="{$item['width']}"
height="{$item['height']}">
<br><br><br><br></center></td></tr>
HTML;
}
$count++;
}