note 118372 added to function.simplexml-load-file
| From: | Rich | Date: | Tue, 24 Nov 2015 14:51:54 +0000 |
| Subject: | note 118372 added to function.simplexml-load-file | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-204219@lists.php.net to get a copy of this message | ||
I stumbled on this: a single element with a simple string in it becomes a string, but a single
element with a *space* in it becomes an Array, with one element, the string space.
I'm sure to XML mystics this is wise and wonderful but it really confused me, and I thought it
might confuse others.
<?php
$parsed = simplexml_load_string('<container><space>
</space><blank></blank><string>hello</string></container>');
$content = json_decode(json_encode($parsed),TRUE);
var_dump($content);
/* Output is:
array(3) {
'space' => array(1) { â did NOT expect this!
[0] => string(1) " "
}
'blank' => array(0) { }
'string' => string(5) "hello"
}
*/
----
Server IP: 72.52.91.14
Probable Submitter: 81.174.169.217
----
Manual Page -- http://php.net/manual/en/function.simplexml-load-file.php
Edit -- https://master.php.net/note/edit/118372
Del: integrated -- https://master.php.net/note/delete/118372/integrated
Del: useless -- https://master.php.net/note/delete/118372/useless
Del: bad code -- https://master.php.net/note/delete/118372/bad+code
Del: spam -- https://master.php.net/note/delete/118372/spam
Del: non-english -- https://master.php.net/note/delete/118372/non-english
Del: in docs -- https://master.php.net/note/delete/118372/in+docs
Del: other reasons-- https://master.php.net/note/delete/118372
Reject -- https://master.php.net/note/reject/118372
Search -- https://master.php.net/manage/user-notes.php