Still Racking My Brain

From: Stiano_at_Optonline.Net (stiano_at_optonline.net)
Date: 12/30/03


To: php-general@lists.php.net
Date: Tue, 30 Dec 2003 10:24:04 -0500

Okay, I got my pathname straightened out, but I'm still showing the
"unexpected $" message.

But that's after doing $[var name] = $_POST['var name']; for everything
with a $ in front of it. Can someone please let me know what I'm not
understanding here?

The code is, again, below.

Thank you very much.

Steve Tiano

-------------------------------------------

// image index
// generates an index file containing all images in a particular directory

//point to whatever directory you wish to index.
//index will be written to this directory as imageIndex.html
$dirName = "c:/csci/mm";
$dp = opendir($dirName);
chdir($dirName);

//add all files in directory to $theFiles array
while ($currentFile !== false){
  $currentFile = readDir($dp);
  $theFiles[] = $currentFile;
} // end while

//extract gif and jpg images
$imageFiles = preg_grep("/jpg$|gif$/", $theFiles);

$output = "";
foreach ($imageFiles as $currentFile){
  $output .= <<<HERE
<a href = $currentFile>
  <img src = "$currentFile"
       height = 50
       width = 50>
</a>

HERE;

} // end foreach

//save the index to the local file system
$fp = fopen("imageIndex.html", "w");
fputs ($fp, $output);
fclose($fp);
//readFile("imageIndex.html");
print "<a href = $dirName/imageIndex.html>image index</a>\n";

 ?>

--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .



Relevant Pages

  • Is It Just a Matter of Getting the Pathname Righr?
    ... My Hard Drive:/ followed by the exact name of every last folder until I ... come to the folder containing the GIFs and JPEGs I want to index and follow ... // generates an index file containing all images in a particular directory ... $currentFile = readDir; ...
    (php.general)
  • Re: Help with file reads
    ... entirety. ... // generates an index file containing all images in a particular ... $currentFile = readDir; ... foreach { ...
    (alt.php)