hello world...
i'm new to PHP (this is my second code) and i would like to learn this language.
Now I'have experience with actionscript and mybe my current code is not working because i'm fllowing the same code architecure.

The problem is:
I want to read the content inside a folder (on server) and write this information into a file.

  • image_fotos

[INDENT]

  • [+]somefolder

[/INDENT]
[INDENT][INDENT]

  • [-]file.jpg
    [-]file2.jpg
    [-]bleble.jpg
    [-]tralala.png
    [-]lolo.swf

[/INDENT]
[+]someotherfolder
[/LIST][/INDENT]
[INDENT][INDENT]

  • [-]fil25e.jpg
    [-]file28.jpg
    [-]bleble78.jpg
    [-]tralalagre.png
    [-]lolo123.swf

[/INDENT][/INDENT][/LIST]

Yesterday i made this but looks like my theory was wrong...

<?php

$dir='/images_photos';
$folders =scandir($dir);

for($i=0;$i<=count($folders);$i++){

${"path".$i}="/$dir/$folders[i]/$folders[i].xml";
${"img_".$folders."".$i}=scandir($folders[i]);
${"str_".$folders."".$i}="<all_images>";

for($j=0;$j<=count(${"img_".$folders."".$i});$j++){
	${"str_".$folders."".$i}.="<image name=".${"img_".$folders."".$i}[j]."/>";
}

${"str_".$folders."".$i}.="</all_images>";
${"open".$i} = fopen(${"path".$i}, 'w'); 
${"write".$i} = fwrite(${"open".$i}, stripslashes(${"str_".$folders."".$i}); 

if(${"write".$i}){
	echo "&thefile".$i."=".${"path".$i}."&"; 
}


}



?>

how can i fix this????
Thanks
Pepe

    looks like the php help is great... it's very well documented.
    I know i will learn faster that actionscript

    
    
    <?php
    $folder="/images_photos";
    
    
    function sort_by_mtime($file1,$file2) {
        $time1 = filemtime($file1);
        $time2 = filemtime($file2);
        if ($time1 == $time2) {
            return 0;
        }
        return ($time1 < $time2) ? 1 : -1;
    }
    
    
    if ($handle = opendir(".".$folder)) {
        while (false !== ($file = readdir($handle))) {
            if ($file != "." && $file != "..") {
    
    $xml_file="."."$folder/$file/$file.xml";
                $html_array = glob(".$folder/$file/*.jpg");
    
    	usort($html_array,"sort_by_mtime");
    	$str_temp="<images>";
    	foreach ($html_array as $filename) {
    	  $str_temp.="<img id=".substr($filename, 2)." />";
    
    	}
    	$str_temp.="</images>";
    	$open=fopen("$xml_file",'w');
    	$write = fwrite($open, stripslashes($str_temp));  
    	echo "$xml_file";
    	echo "$str_temp";
    	echo "<br><br>";
    	fclose($open);
    
        }
    }
    closedir($handle);
    }
    ?> 
    
    
    
      Write a Reply...