/    Sign up×
Community /Pin to ProfileBookmark

create xml file by php reading folder

i have a php file in which i read a folder by this code

$image_file_path = ‘images’;

$d = dir($image_file_path) or die(“Wrong path: $image_file_path”);
while (false !== ($entry = $d->read())) {
if($entry != ‘.’ && $entry != ‘..’ && !is_dir($dir.$entry))
$aqw=$entry.’,’.$aqw;
}

$d->close();

i want to create a xml file now like now

<images>
<image url=”images/01.png” />
<image url=”images/02.png” />
<image url=”images/03.png” />
<image url=”images/04.png” />
<settings>

<!– 5000 equals 5 seconds –>
<!– Delay between slide animation –>

<delay>5000</delay>

<!– animation duration and 1 equals 1 second –>

<animationDuration>.8</animationDuration>

</settings>

</images>

what i do for it or what is the coding for this.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@hastxApr 06.2010 — I haven't tested this, but since you are just looking for png files, I would do something like this to avoid all the checks '.' and '..', etc.

[code=php]
<?php
$img_dir = 'images';
$file_out = 'images.xml';

$xml = "<images>n";

foreach (glob($img_dir."/*.png") as $filename) {
$xml .= "<image url="$filename" />n";
}

$xml .= 'settings';//....whatever settings

$xml .= "</images>n";

file_put_contents($file_out,$xml);
?>
[/code]
Copy linkTweet thisAlerts:
@ilyasbasheerauthorApr 09.2010 — Thanks a lot.
×

Success!

Help @ilyasbasheer spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...