pneudralics Posted September 10, 2009 Share Posted September 10, 2009 I'm trying to write all jpg names that is named with a number to an xml file. Whenever I echo it and look at the source I can see that they are displaying. When I check the test.xml file it only shows one value. How can I make it write more than one value to the xml file? //Set directory $search_dir = '.'; $dp = opendir ($search_dir); //List directories while ($item = readdir ($dp) ) { if ( (is_dir ($item)) AND (substr($item, 0, 1) != '.') ) { echo "$item<br />\n"; } } rewinddir ($dp); //Reset pointer //List files while ($item = readdir ($dp) ) { if ( (is_file ($item)) AND (substr($item, 0, 1) != '.') ) { //Get file size $fs = filesize ($item); //Get file modification date $lm = date ('F j, Y' , filemtime($item)); //Find image $imagepattern = '/^([0-9]){1,}.jpg$/'; $imagesubject = "$item"; if (preg_match($imagepattern, $imagesubject, $imagematches)) { //Open file $imagesubject2 = "<image Thumb=\"tn_$imagesubject\" Large=\"$imagesubject\"/>"; if ($fp = fopen ('test.xml', 'w')) { fwrite ($fp, "$imagesubject2"); fclose ($fp); echo "$imagesubject2"; } } } } Link to comment https://forums.phpfreaks.com/topic/173819-writing-file-names-to-a-file/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.