Voting

: two minus one?
(Example: nine)

The Note You're Voting On

Rich
9 years ago
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"
}
*/

<< Back to user notes page

To Top