Could I get some help trouble shooting my code? For some reason I'm not getting anything to copy into the $insertpics variable or printing out. What am I missing?
also, any hints toward making the code simpler and/or work better would be greatly appreciated.
thanks
code follows 🙂
<?
function getPics($dirName) {
global $insertpics;
$dp = opendir($dirName);
chdir($dirName);
while ($currentFile !== false){
$currentFile = readDir($dp);
$theFiles[] = $currentFile;
}
$gifs = preg_grep("/gif$/", $theFiles); sort($gifs);
$jpgs = preg_grep("/jpg$/", $theFiles); sort($jpgs);
$a = $b = -1;
foreach ($gifs as $gifFile) {
$a++;
$b=0;
$c++;
foreach($jpgs as $jpgFile) {
if($b>=$a) break;
$b++;
$insertpics .= "<a href=javascript:opener('pics/$jpgFile')><img style='border-color:#8888aa; border-width:1px; border-style:solid;' src='pics/$gifFile'></a>\r";
if($c == 2) {
print "<br>\r";
$c=0;
}
}
}
}
if($pageid == "pics") {
$title = "Pictures - One Way Youth";
getPics("pics");
$bodytext = $insertPics;
}
else return;
?>
<html> <head>
<title><? print $title ?></title>
</head> <body>
<? print "$bodytext"; ?>
</body> </html>