File tree Expand file tree Collapse file tree 1 file changed +24
-47
lines changed Expand file tree Collapse file tree 1 file changed +24
-47
lines changed Original file line number Diff line number Diff line change @@ -325,58 +325,35 @@ $upper = str_upper('TeSt');
325325Converts xml string to array:
326326
327327```php
328- $array = xml_to_array(' < ? xml version=" 1.0" encoding=" UTF-8" ? >
329- < root>
330- < tasks>
331- < task priority=" low" >
332- < to> John< /to>
333- < from> Jane< /from>
334- < title> Go to the shop< /title>
335- < /task>
336- < task priority=" medium" >
337- < to> John< /to>
338- < from> Paul< /from>
339- < title> Finish the report< /title>
340- < /task>
341- < task priority=" high" >
342- < to> Jane< /to>
343- < from> Jeff< /from>
344- < title> Clean the house< /title>
345- < /task>
346- < /tasks>
347- < /root>
328+ $array = xml_to_array(' < ? xml version=" 1.0" ? >
329+ < Guys>
330+ < Good_guy Rating=" 100" >
331+ < name> Luke Skywalker< /name>
332+ < weapon> Lightsaber< /weapon>
333+ < /Good_guy>
334+ < Bad_guy Rating=" 90" >
335+ < name> Sauron< /name>
336+ < weapon> Evil Eye< /weapon>
337+ < /Bad_guy>
338+ < /Guys>
348339' );
349340
350341// [
351- // ' tasks' => [
352- // ' task' => [
353- // 0 => [
354- // ' to' => ' John' ,
355- // ' from' => ' Jane' ,
356- // ' title' => ' Go to the shop' ,
357- // ' @attributes' => [
358- // ' priority' => ' low' ,
359- // ],
360- // ],
361- // 1 => [
362- // ' to' => ' John' ,
363- // ' from' => ' Paul' ,
364- // ' title' => ' Finish the report' ,
365- // ' @attributes' => [
366- // ' priority' => ' medium' ,
367- // ],
368- // ],
369- // 2 => [
370- // ' to' => ' Jane' ,
371- // ' from' => ' Jeff' ,
372- // ' title' => ' Clean the house' ,
373- // ' @attributes' => [
374- // ' priority' => ' high' ,
375- // ],
376- // ],
342+ // "Good_guy" => [
343+ // "@attributes" => [
344+ // "Rating" => "100",
377345// ],
346+ // "name" => "Luke Skywalker",
347+ // "weapon" => "Lightsaber",
378348// ],
379- // ];
349+ // "Bad_guy" => [
350+ // "@attributes" => [
351+ // "Rating" => "90",
352+ // ],
353+ // "name" => "Sauron",
354+ // "weapon" => "Evil Eye",
355+ // ],
356+ // ]
380357```
381358
382359Alternatively, you can pass an instance of `SimpleXMLElement` object, to get the same results.
You can’t perform that action at this time.
0 commit comments