Quantcast
Viewing latest article 3
Browse Latest Browse All 4

Answer by Kinglish for Looping through a SimpleXML with foreach in php

$xml = simplexml_load_file('https://np.tritondigital.com/public/nowplaying?mountName=KFRQFMAAC&numberToFetch=3&eventType=track&request.preventCache=1621376522745');$tracks = [];foreach($xml->{'nowplaying-info'} as $item){     $properties = [];     foreach ($item->property as $prop)  $properties[] = (String) $prop;     $tracks[]=$properties;}print_r($tracks);

preview it here: https://www.tehplayground.com/8zX2DrFsjVjT1IUK


// output: Array(    [0] => Array        (            [0] => 03:07            [1] => 1622057699278            [2] => LIVE AND LET DIE            [3] => 18281            [4] => PAUL MCCARTNEY & WINGS        )    [1] => Array        (            [0] => 04:20            [1] => 1622057449584            [2] => DREAMS            [3] => 18269            [4] => FLEETWOOD MAC        )    [2] => Array        (            [0] => 05:03            [1] => 1622057144393            .....

Viewing latest article 3
Browse Latest Browse All 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>