php - reading data from xml and create an array object



I am new to php, I am using metro-websign for creating my website. There is a plugin taking an array. The following code works fine:





<? php
$photoNewsPath = array(
"photo/committees/spirit-rock/20150203-anna.jpg",
"photo/news/20150207 - 100 day.jpg"
);

$photoNewsTitle = array("Post your photos on the website", "100 school day = pajama day fun");

var_dump($photoNewsPath);

$tile[] = array(
"type" => "slideshow",
"images" => $photoNewsPath,
"classes" => "");



Now I try to move the array content to an xml file:





<? php
$photonews = simplexml_load_file("config\photonews.xml") or die("Error: Cannot create object");

foreach($photonews - > news as $news) {
$photoNewsPath[] = (string) $news - > path;
}

var_dump($photoNewsPath);

$tile[] = array(
"type" => "slideshow",
"images" => $photoNewsPath,
"classes" => ""); ?>



Now the plugin doesn't work anymore. I use var_dump to dump the array from both code spinets. The results are identical. What could make the arrays different so the php plugin fails?


Any clues?


No comments:

Post a Comment