Sunday, September 1, 2013

Count values in array

Count values in array

Counting values with the following code turns no results to my array.
Would appreciate any help on what I did wrong thanks.
<?php
$xml=simplexml_load_file("sitemap.xml");
$arr = array();
foreach($xml->url as $child)
{
?>
if (isset($child->loc)) {
echo "true";
$arr[] = $child->loc;
} else {
echo "error";
echo $child->loc;
}
}
print_r(array_count_values($arr));
?>

No comments:

Post a Comment