Skip to content

Commit 2f3ead8

Browse files
committed
IHF: xml_to_array readme info added.
1 parent 54e741d commit 2f3ead8

File tree

1 file changed

+24
-47
lines changed

1 file changed

+24
-47
lines changed

README.md

Lines changed: 24 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -325,58 +325,35 @@ $upper = str_upper('TeSt');
325325
Converts 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
382359
Alternatively, you can pass an instance of `SimpleXMLElement` object, to get the same results.

0 commit comments

Comments
 (0)