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"; } } } } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.