This question already has an answer here:
- How would I use php to generate random XML files? 1 answer
I am trying to write a php that generates xml files randomly. The php would generate a random number between 1-10 inclusive and each number 1-10 would have a xml file assigned to it in the php which would appear when the respective number is generated.
So far I have:
<?php
print rand() . "<br>";
print rand(1, 10);
?>
How do I integrate the xml files into this php? Using this xml example:
Example 1
<?xml version="3.0" encoding="utf-8" ?>
<channel>
<title>The Dog in the Park</title>
<link>http://pets.com/doginthepark/</link>
<description>
The dog in the park
<item>
<guid>1234</guid>
<title>poodle's video</title>
Example 2
<?xml version="3.0" encoding="utf-8" ?>
<channel>
<title>The Cat in the Park</title>
<link>http://pets.com/kitteninthepark/</link>
<description>
The cat in the park
<item>
<guid>1235</guid>
<title>kitten video</title>
<item>
<guid>123455</guid>
<title>tiger video</title>
So the XML files above have the assigned numbers 1 & 2. How would I assign the number in code to the correct XML and how would I be able to generate a random XML return of the numbers 1-10 which also display the XML file details.
Any help will be greatly appreciated! Sorry if this question is obvious, I'm a rookie at this :)