something happening in my script and i cant figure out whats going on, basically i have a array of products, and with this array im populating the items in the foreach loop to a xml file, the problema is that in the first nodes appears empty data, and im sure that i dont have emmpty data in the array, i already tried just printing the data in plaintext and works fine, only when im looping and creating the xml file.
My script:
$xml = new SimpleXMLElement('<products/>');
for ($i = 0; $i <= sizeof($catalog); ++$i) {
$track = $xml->addChild('product');
$track->addChild('name', $i . $catalog[$i]["name"]);
$track->addChild('brand', $catalog[$i]["brand"]);
}
Header('Content-type: text/xml');
print($xml->asXML());