I have the following XML structure stored in my database:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Payouts>
<Range end="1" start="1">900</Range>
<Range end="2" start="2">650</Range>
<Range end="3" start="3">450</Range>
<Range end="4" start="4">330</Range>
<Range end="5" start="5">230</Range>
<Range end="6" start="6">175</Range>
<Range end="7" start="7">120</Range>
<Range end="8" start="8">95</Range>
<Range end="9" start="9">80</Range>
<Range end="10" start="10">70</Range>
<Range end="15" start="11">50</Range>
<Range end="20" start="16">35</Range>
<Range end="25" start="21">25</Range>
<Range end="30" start="26">18</Range>
<Range end="40" start="31">15</Range>
<Range end="50" start="41">14</Range>
<Range end="75" start="51">13</Range>
<Range end="100" start="76">12</Range>
<Range end="125" start="100">11</Range>
<Range end="150" start="126">10</Range>
<Range end="200" start="151">9</Range>
<Range end="350" start="201">8</Range>
<Range end="360" start="351">7</Range>
<Range end="380" start="361">6</Range>
<Range end="400" start="381">5</Range>
<Range end="420" start="401">4</Range>
<Range end="440" start="421">3</Range>
<Range end="460" start="441">2</Range>
<Range end="480" start="461">1</Range>
<Range end="500" start="481">1</Range>
<Range end="520" start="501">1</Range>
</Payouts>
This is basically a range of options. I'd like to filter through these results and get the value in the end and start and then display the value for that row.
The output would be something like the following:
1st - 900
2nd - 650
3rd - 450
4th - 330
5th - 230
6th - 175
7th - 120
8th - 95
9th - 80
10th - 70
11th to 15th - 50
16th to 20th - 35
21th to 25th - 25
I tried to read the XML file with the following code:
$payout_xml = $event_details[0]['PAYOUT_DETAILS'];
$xml = new SimpleXMLElement($payout_xml);
echo "The Simple Element is: ".print_r($xml);
echo 'single value: <br />';
echo $xml->Payouts->Range->end; // get single value
echo "end of data";
When I print_r the $payout_xml I get the following results:
SimpleXMLElement Object
(
[Range] => Array
(
[0] => 900
[1] => 650
[2] => 450
[3] => 330
[4] => 230
[5] => 175
[6] => 120
[7] => 95
[8] => 80
[9] => 70
[10] => 50
[11] => 35
[12] => 25
[13] => 18
[14] => 15
[15] => 14
[16] => 13
[17] => 12
[18] => 11
[19] => 10
[20] => 9
[21] => 8
[22] => 7
[23] => 6
[24] => 5
[25] => 4
[26] => 3
[27] => 2
[28] => 1
[29] => 1
[30] => 1
)
)
The Simple Element is: 1
I'm not accessing the data though. How can I do this?
$event_details[0]['PAYOUT_DETAILS']&$xmlto make sure they actually contain data?