Jump to content

output folder contents to xml file with php


PeterPopper

Recommended Posts

I have a folder with some images and I want to simply grab all the images and make an xml file. This is for a Flash photo gallery.

 

The xml file will look like this:

<?xml version="1.0" encoding="UTF-8" ?>
<data >
    <image url="images/Lisa_Archer_1.jpg" thumb="images/thumbs/Lisa_Archer_thumb_1.jpg" />
</data>

 

 

Thanks.

I am just looking for a simple PHP code that opens a directory, get the names of all the files, and put the file names in the XML schema then do an echo, like this:

 

<?php echo '<?xml version="1.0" encoding="utf-8"?>'; ?>
<data >
<?php do{?>
<image url="images/" . $imageName . " thumb="images/thumbs/ . $imageName . "_thumb" .  '"' />
</data >
?>

Right, read up on glob. Given that you just posted the same question I take it you did not even bother to look into that function at all. As if you would have looked at the first example:

 

<?php
foreach (glob("*.txt") as $filename) {
    echo "$filename size " . filesize($filename) . "\n";
}
?>

 

You would have an outline for what you need to do to get your images.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.