On 10 Aug., 16:07, Geoff Berrow <blthe...@ckdog .co.ukwrote:
Message-ID:
<e4e3f8fb-8fb9-4599-a975-f942c9214...@k7 g2000hsd.google groups.comfrom
Effix contained the following:
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 *01100010011011 00010000000110
001101101011011 001000110111101 100111001011
100110001101101 111001011100111 010101101011htt p://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='im ages/galleri/thumbs/';
$display_dir='i mages/galleri/';
$table="<table id='thumbnails' >\n<tr>\n";
$count=1;
//loop through filenames
foreach($filena me_array as $filename){
$filename= substr(strrchr ($filepath,"/"), 0, 20) ;
$table.=($count %6==0)?"</tr>\n<tr>\n":"" ;
$table.="<td><a href='".$displa y_dir."".$filen ame."' ><img
src='".$thumbs_ dir."".$filenam e."'></a></td>\n";
$count++;
}
//finish off table row
while($count%6! =0){
$table.="<td>&n bsp;</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 :) )