$abspath_folder = "/home/santm/public_html/PamelasCreation/images";
if (is_dir($abspath_folder)) {
if ($handle = opendir($abspath_folder)) {
while (false !== ($file = readdir($handle))) {
if ($file != '.' && $file != '..' && $file != 'CVS' && $file != 'index.html') {
// end of reading the directory
// santm print_r($the_array);
// making sure the array only has our jpg image starting with a number
foreach ($the_array as $img) {
if (!is_dir($abspath_folder . '/' . $img)) {
if (eregi($type, $img) && eregi("^[0-9]", $img)) {
for ($k = 0; $k < $i; $k++) {
echo "santm $the_image[$k] \n";
$full_name = explode(".", $the_image[$k]);
$short_name = $full_name[0];
$foo_img = 'images/' . $short_name;
$pre_name = explode(".", $the_image[$k - 1]);
$pre_short_name = $pre_name[0];
$next_name = explode(".", $the_image[$k + 1]);
$next_short_name = $next_name[0];
echo " short $short_name \n";
// doing dirty way with system call for placing the header
$head_out = shell_exec('cat /home/santm/head.pam.inc');
$write_handle = fopen("/home/santm/public_html/PamelasCreation/$short_name.html", "w+");
fwrite($write_handle, $head_out);
<div class= \"big_photo\">\\n
<img src=\"images/previous.gif\" alt=\"next\" border=\"0\">\\n");
if ((!$pre_short_name) || (!$next_short_name)) {
<a href=\"index.html\" width=\"90%\">\\n");
<img src=\"images/home.gif\" alt=\"home\" border=\"0\">\\n");
fwrite($write_handle, "\\n");
fwrite($write_handle, "\\n");