如何传递由for循环处理的数组中的所有值?

时间:2015-01-05 05:37:18

标签: php

<?php

    $xml = simplexml_load_file("sample.xml");

    echo " ". $xml->getName() . "<br />";

    foreach($xml->children()->children() as $child)

      {

      $a=$child->getName() . "<br />";
        array_push($a);
        echo $a;

      }

?> 

1 个答案:

答案 0 :(得分:0)

试试这个

<?php
    $arr = array();        
    $xml = simplexml_load_file("sample.xml");

    echo " ". $xml->getName() . "<br />";

    foreach($xml->children()->children() as $child)
    {
        $a=$child->getName() . "<br />";
        $arr[] = $a;
        echo $a;
    }
?>