On 10 Aug., 16:07, Geoff Berrow <blthe...@ckdog.co.ukwrote:
Quote:
Message-ID:
<e4e3f8fb-8fb9-4599-a975-f942c9214...@k7g2000hsd.googlegroups.comfrom
Effix contained the following:
>
Quote:
Thank you for yor solution Geoff. Your right I have my files in an
arrray. I use the glob() function. It seems theres no way to strip the
path from the glob() function so my array contains path and filename.
Is there an alternative to glob which only gives me the filenames?
could scandir() work?
>
Well presumably you know the path(s). *You just need the portion to the
right of the last '/' *
>
strrchr () will give you everything from the last '/' onwards
>
so
>
$filename= substr(strrchr ($filepath,"/"), 1)
--
Geoff Berrow *0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011http://slipperyhill.co.uk
Aah I see I was trying to use trim() to remove the path from the array
but that didnt work :)
Altohug I cant seem to get strrchr to work either, im sorry to be such
a bother. Apparently it strips the path but no filename appears efter
the last /
here is my code so far, not modified much (not yet anyways :) ) from
your original suggestion.
//set up variables
$filename_array= glob('images/galleri/thumbs/*.jpg');
$filepath= 'images/galleri/thumbs/' ;
$thumbs_dir='images/galleri/thumbs/';
$display_dir='images/galleri/';
$table="<table id='thumbnails'>\n<tr>\n";
$count=1;
//loop through filenames
foreach($filename_array as $filename){
$filename= substr(strrchr ($filepath,"/"), 0, 20) ;
$table.=($count%6==0)?"</tr>\n<tr>\n":"";
$table.="<td><a href='".$display_dir."".$filename."' ><img
src='".$thumbs_dir."".$filename."'></a></td>\n";
$count++;
}
//finish off table row
while($count%6!=0){
$table.="<td> </td>\n";
$count++;
}
$table.="<tr>\n</table>";
//echo table to screen;
echo $table;
?>
This results in a page with a table that look like this
<table id='thumbnails'>
<tr>
<td><a href='images/galleri//' ><img
src='images/galleri/thumbs//'></a></td>
<td><a href='images/galleri//' ><img
src='images/galleri/thumbs//'></a></td>
<td><a href='images/galleri//' ><img
src='images/galleri/thumbs//'></a></td>
<td><a href='images/galleri//' ><img
src='images/galleri/thumbs//'></a></td>
<td><a href='images/galleri//' ><img
src='images/galleri/thumbs//'></a></td>
</tr>
<tr>
<td><a href='images/galleri//' ><img
src='images/galleri/thumbs//'></a></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<tr>
</table>
What am I doing wrong?
-Effix (beginning to get a bit confused :) )