GooS
Azrael
- Reaction score
- 154
Ok so I made a gallery script in PHP and it worked, but I wanted to customize it even more so it presents name, size (width and height) and filetype based on image name (easy updating).
Well here's the code:
It explodes and works however the first returned array piece breaks at a place that I don't want.
If the pictures name is: Miracle of Birth_1280x1024_.jpg
it returns:
Name: M
Size: 1280x1024
Type: .jpg
There, the name is wrong and I don't know why since it should only break it up when it meets an underscore.
I could easily have just missed something, but I can't find it.
Well here's the code:
PHP:
<?php
$count = 0;
if ($handle = opendir('sub/portfolio/abstract'))
{
while (false!== ($file = readdir($handle)))
{
if ($file!= "." && $file!= "..")
{
$fileexp = (explode("_",$file));
echo "<td align=\"center\"><a href=\"sub/portfolio/abstract/$file\"><img src=\"sub/portfolio/abstract/$file\" width=\"100\" height=\"100\" border=\"0\"></a><br />Name: $file[0]<br />Size: $fileexp[1]<br />Type: $fileexp[2]<br></td>";
$count = $count +1;
if ($count == 4)
{
echo "</tr><tr><td colspan=\"4\" style=\"background-color: #8b1300; height: 1px; border-top: 1px solid #ff2300; border-bottom: 1px solid #360700;\"></td></tr><tr>";
$count = 0;
}
}
}
echo "</table>";
closedir($handle);
}
?>
It explodes and works however the first returned array piece breaks at a place that I don't want.
If the pictures name is: Miracle of Birth_1280x1024_.jpg
it returns:
Name: M
Size: 1280x1024
Type: .jpg
There, the name is wrong and I don't know why since it should only break it up when it meets an underscore.
I could easily have just missed something, but I can't find it.