Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Create an array from files in directory?
Old 06-20-2005, 04:33 PM Create an array from files in directory?
Average Talker

Posts: 15
Trades: 0
I'm trying to make a slideshow with some images I have in a directory. I found a javascript that will create the show, but I have to manually put in the filename for each image that I want in the show. Is there not a way to use PHP to take filenames from a directory and put them in an array?

I need it to look like this:

Picture[1] = 'Image001.jpg';
Picture[2] = 'Image002.jpg';
Picture[3] = 'Image003.jpg';
Picture[4] = 'Image004.jpg';
and so on...

Any suggestions?

J2
jacannon2 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-22-2005, 01:25 AM
Experienced Talker

Posts: 32
Trades: 0
that funny i hat ethe same problem the other day i made the script that will make the text i mean you woul dhave to make little tweaks to it but can you give me the link to the script that does that please if you dont mind. here is the script that you have to tweek to get the fiels from the folder
PHP Code:
<?php

if ($handle opendir('pics/test/')) 
{
   
$url ='pics/test/';
   
   
/* This is the correct way to loop over the directory. */
   
$i=0;
   while (
false !== ($file readdir($handle))) 
   {   
           if (
$file != "." && $file != ".."
        {
           
//     print "<br>";  
               
echo "leftrightslide["$i "]='<img src=\"" $url "/" $file "\" border=1>'";
             
$i++;
           }
        else
        {
            
$i=0;
            
        }
          
   }
   
closedir($handle);
}
?>
this is what it outputs

[HMTL]

leftrightslide[0]='<img src="pics/test/Picture 021.jpg" border=1>'
leftrightslide[1]='<img src="pics/test/Picture 031.jpg" border=1>'
leftrightslide[2]='<img src="pics/test/Picture 007.jpg" border=1>'
leftrightslide[3]='<img src="pics/test/Picture 002.jpg" border=1>'
leftrightslide[4]='<img src="pics/test/Picture 004.jpg" border=1>'
[/HTML]

can you hook me up with the script that you have
rcubes85 is offline
Reply With Quote
View Public Profile
 
Old 06-22-2005, 09:22 AM
Average Talker

Posts: 15
Trades: 0
Thanks for the reply. Here's the script I'm trying to use...

http://www.codelifter.com/main/javas...lideshow3.html

I basically want to create a slideshow using all the images in a directory, but I don't want to have to type each image's name in the script for it to work.

Thanks again. :-)
jacannon2 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Create an array from files in directory?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.01000 seconds with 12 queries