PHP kod foreach

0 Cevap php

Ben onun değerlerini almak için bir xml belge üzerinden yineleme yapmak istiyorum. Verilen kod bakın

foreach ($xml->children() as $key1=>$value1 /*($xml->children() as $second_gen)*/ ) {
    echo ' 1 ' .$key1.' '.$value1.'<br>';

    foreach ($second_gen as $key2=>$value2) {
        echo ' ___2 ' .$key2.' '.$value2.'<br>';

    }
}

So what I want to do is to make $second_gen equals to the children of the each current iteration of the loop. I was able to do this by putting it in the foreach, but this prevented me from using key/value. So is there any solution to get both? Thanks!

0 Cevap