Reply to Re: foreach and str_replace

Your name:

Reply:


Posted by Confused but working on it on 09/16/07 22:17

On 2007-09-16 14:58:31 -0700, "Rik Wasmus" <luiheidsgoeroe@hotmail.com> said:
>
> This does NOT alter $file. $file is not taken as a reference and altered
> inside str_replace();
>
> $file = str_replace('thumbs/', '', $file);

Yeah, that was dumb.

>> thx..ron
>
> Why do your images live in a thumbs dir and you still want an '/images/'
> link?
>
> However, this may help you:
>
> <?php
> foreach (glob("thumbs/*.jpg") as $file){
> $filename = basename($file);
> echo "<a href='images/$filename'><img src='$filename'
> class='pad1em'></a>";
> }
> ?>
>
>
> --
> Rik Wasmus

My thumbs live in thumbs and the full size in images. Made sense to me.
I export from iPhoto a set of thumbs and then the larger pics.

<?php
foreach (glob("thumbs/*.jpg") as $file){
$filename = basename($file);
echo "<a href='images/$filename'><img src='thumbs/$filename'
class='pad1em'></a>";
}
?>

Works great. I got those file markers and realized you took out the
"thumbs/" in the echo statement.

Uploaded and the files are in order of filename.

Next week maybe I'll learn how to take a directory named images and
create thumbs on the fly. Might hve been easier. :)

Thanks for all the help.

Ron

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация