Nel tutorial di oggi imparerete come trasformare la struttura di una directory di immagini in XML.

 
< ?php
header("Content-Type: text/xml"); //set the content type to xml
// Initialize the xmlOutput variable
$xmlBody = ;
$dir = "images/gallery1/"; // Specify Directory where images are
$xmlBody .= ""; // Start XMLBody output
// open specified directory using opendir() the function
$dirHandle = opendir($dir);
// Create incremental counter variable if needed
$i = 0;
while ($file = readdir($dirHandle)) {
// if file is not a folder and if file name contains the string .jpg
if(!is_dir($file) && strpos($file, ‘.jpg’)){
$i++; // increment $i by one each pass in the loop
$xmlBody .=

‘ . $i .
. $dir . . $file .
;
} // close the if statement
} // End while loop
closedir($dirHandle); // close the open directory
$xmlBody .= "";
echo $xmlBody; // output the gallery data as XML file for flash
 

fonte: www.sastgroup.com ? Vai al post originale