PHP parses XML into arrays online and other XMLcode & lt ;? Xmlversion = & quot; 1.0 & quot; encoding = & quot; UTF-8 & quot ;? & Gt; & lt; root & gt; & lt; a & gt; & lt; bname = 'name' value PHP parses XML into an array online, etc.
XML code
Resolved to an array:
PHP code
Array( [0]=>Array( [0]=>Array(name=>'name',value=>'value'), [1]=>Array(name=>'name',value=>'value'), [2]=>Array(name=>'name',value=>'value') ), [1]=>Array( [0]=>Array(name=>'name',value=>'value'), [1]=>Array(name=>'name',value=>'value'), [2]=>Array(name=>'name',value=>'value') ), [2]=>Array( [0]=>Array(name=>'name',value=>'value'), [1]=>Array(name=>'name',value=>'value'), [2]=>Array(name=>'name',value=>'value') ),)
------ Solution --------------------
PHP code
XML; $ obj = simplexml_load_string ($ xml); foreach ($ obj as $ k = >$ v) {$ temp = array (); foreach ($ v-> B as $ sv) {$ a = (array) $ sv-> attributes (); $ temp [] = $ a ['@ bubutes'];} $ arr [] = $ temp;} print_r ($ arr );
------ Solution --------------------
PHP code
$s =<<< XML
XML;$xml = simplexml_load_string($s);foreach($xml as $item1) { $r = array(); foreach($item1 as $item2) { $t = array(); foreach($item2->attributes() as $k=>$v) { $t[] = array($k => "$v"); } $r[] = $t; } $res[] = $r;}print_r($res);