Invité
Invité n'ayant pas de compte PHPfrance
05 avr. 2005, 22:00
voici le code...., le problème ma variable $tofile ne prend pas l'information dans la fonction situé en gras.... Cependant je fait un print_r de la variable et pourtant elle s'affiche à l'écran ?!?! Des idée ?
include("configuration.inc.php");
// ******************************* Ouverture du fichier XML *******************
$handle = fopen("images.xml","w");
// ****************************************************************************
// ************************* SECTION ÉCRITURE AU FICHIER *********************
$tofile = "<" . "?" . "xml version=\"1.0\"" . "?" . ">\n";
$tofile .= "<images>\n";
function traverseDirTree($base,$fileFunc,$dirFunc=null,$afterDirFunc=null){
$subdirectories=opendir($base);
while (($subdirectory=readdir($subdirectories))!==false){
$path=$base.$subdirectory;
if (is_file($path)){
if ($fileFunc!==null) $fileFunc($path);
}else{
// ********************** Ici ont affiche le "." et le ".." *****
// if ($dirFunc!==null) $dirFunc($path);
// **************************************************************
// *************** Fonction pour les sous répertoire *******
if (($subdirectory!='.') && ($subdirectory!='..')){
traverseDirTree($path.'/',$fileFunc,$dirFunc,$afterDirFunc);
}
// **********************************************************
if ($afterDirFunc!==null) $afterDirFunc($path);
}
}
}
function outputPath($path){
$level=substr_count($path,'/');
for ($i=1;$i<$level;$i++){}
$fichier = basename($path);
print_r($fichier);
$tofile .= "\t<pic>\n";
$tofile .= "\t\t<image>http://SITE WEB/". $fichier. "</image>\n";
$tofile .= "\t</pic>\n";
}
traverseDirTree('c:/MON CHEMIN/','outputpath','outputpath');
$tofile .= "</images>\n";
fwrite($handle,$tofile);
fclose($handle);