|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #51553 bug in simplexmlelement count example
Submitted: 2010-04-14 00:37 UTC Modified: 2010-04-14 01:08 UTC
From: sarahnorthway at gmail dot com Assigned:
Status: Not a bug Package: SimpleXML related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: sarahnorthway at gmail dot com
New email:
PHP Version: OS:


 [2010-04-14 00:37 UTC] sarahnorthway at gmail dot com
In the examples for simplexmlelement->count at, the line:

foreach ($elem as $person) {

should be:

foreach ($elem->children() as $person) {


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-14 01:08 UTC]
-Status: Open +Status: Bogus
 [2010-04-14 01:08 UTC]
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

That's not necessary. Did you actually run the code? :)

When you iterate over a SimpleXML element, it's its children you'll get. What else should it be?

daniel@daniel-laptop:~$ php -v; php test.php
PHP 5.3.3-dev (cli) (built: Mar 29 2010 15:35:44) 
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with Xdebug v2.0.5, Copyright (c) 2002-2008, by Derick Rethans
Person 1 has got 3 children.
Person 2 has got 5 children.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Fri Jan 27 09:05:54 2023 UTC