PHP From the xml file below I have to pickup 2 purchase prices including 2 quantities and put them into a table. The xml you see below. I can not get the needed vars out of the array.
<?xml version="1.0" encoding="UTF-8"?><products>
<Product>
<ParentName>22.01.14.10</ParentName>
<Name>3040-100</Name>
<Prices>
<Price min-qty="1" currency="EUR">6,3200</Price>
<Price min-qty="12" currency="EUR">5,3200</Price>
<Price min-qty="24" currency="EUR">4,7200</Price>
</Prices>
</Product>
<Product>
<ParentName>22.01.10</ParentName>
<Name>PDS1C</Name>
<Prices>
<Price min-qty="1" currency="EUR">1,9565</Price>
<Price min-qty="10" currency="EUR">1,6828</Price>
<Price min-qty="20" currency="EUR">1,4828</Price>
</Prices>
</Product>
<Product>
<ParentName>22.01.14</ParentName>
<Name>P1017</Name>
<Prices>
<Price min-qty="1" currency="EUR">4,9337</Price>
<Price min-qty="20" currency="EUR">3,9699</Price>
</Prices>
</Product>
</products>
With this I fill the prices array:
foreach($product->{'Prices'}->children() as $key => $price)
{
$prices[ "" . $price->attributes()->{'min-qty'}] = mysql_real_escape_string(str_replace(',','.',"" . $price[0]));
}
ksort($prices); // sort array
Here the results:
Array
(
[1] => 6.3200
[12] => 5.3200
[24] => 4.7200
)
Array
(
[1] => 1.9565
[10] => 1.6828
[20] => 1.4828
)
Array
(
[1] => 4.9337
[20] => 3.9699
)
Now I have to fill the vars to put the vars into the table:
$qfirst = ''; // should be 1
$pfirst = ''; // should be 6.3200
$qsec = ''; // should be 12
$psec = ''; // should be 5.3200
What I try I do not get the data into the 4 vars.
$product->{'Prices'}->children()- wait, that syntax is valid?