Using the rand () php function to display random xml files -
this question has answer here:
i trying write php generates xml files randomly. php generate random number between 1-10 inclusive , each number 1-10 have xml file assigned in php appear when respective number generated.
so far have:
<?php print rand() . "<br>"; print rand(1, 10); ?>
how integrate xml files php? using xml example:
example 1
<?xml version="3.0" encoding="utf-8" ?> <channel> <title>the dog in park</title> <link>http://pets.com/doginthepark/</link> <description> dog in park <item> <guid>1234</guid> <title>poodle's video</title>
example 2
<?xml version="3.0" encoding="utf-8" ?> <channel> <title>the cat in park</title> <link>http://pets.com/kitteninthepark/</link> <description> cat in park <item> <guid>1235</guid> <title>kitten video</title> <item> <guid>123455</guid> <title>tiger video</title>
so xml files above have assigned numbers 1 & 2. how assign number in code correct xml , how able generate random xml return of numbers 1-10 display xml file details.
any appreciated! sorry if question obvious, i'm rookie @ :)
couldnt put xml files array. on submit of page have
echo file_get_contents($xmlarray[rand(1,10)]);
i presume work. hope helps.
Comments
Post a Comment