-
-
Save scannell/28a6319416738068fdcd to your computer and use it in GitHub Desktop.
simplexml issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Copyright 2004-present Facebook. All Rights Reserved. | |
| $p = new SimpleXMLElement('<parent/>'); | |
| $c = $p->addChild('child', '123'); | |
| $c->addAttribute('attr', 'hi'); | |
| $cattrs = array(); | |
| foreach ($c->attributes() as $k => $v) { | |
| $cattrs[$k] = $v; | |
| } | |
| // $p->children()[0] should be the same node as $c | |
| $pcattrs = array(); | |
| foreach ($p->children()[0]->attributes() as $k => $v) { | |
| $pcattrs[$k] = $v; | |
| } | |
| // the attribute counts should be equal! | |
| echo count($cattrs)."\n"; | |
| echo count($pcattrs)."\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment