diff --git a/reference/simplexml/simplexmlelement/children.xml b/reference/simplexml/simplexmlelement/children.xml index 471e2e0241..6e02d07325 100644 --- a/reference/simplexml/simplexmlelement/children.xml +++ b/reference/simplexml/simplexmlelement/children.xml @@ -175,7 +175,8 @@ int(1) SimpleXMLElement::children returns a node object no matter if the current node has children or not. Use count on the return value to see if there are any - children. + children. As of PHP 5.3.0, SimpleXMLElement::count + may be used instead. @@ -183,6 +184,7 @@ int(1) &reftitle.seealso; + SimpleXMLElement::count count diff --git a/reference/simplexml/simplexmlelement/count.xml b/reference/simplexml/simplexmlelement/count.xml new file mode 100644 index 0000000000..de0d04df7d --- /dev/null +++ b/reference/simplexml/simplexmlelement/count.xml @@ -0,0 +1,101 @@ + + + + + + SimpleXMLElement::count + Counts the children of an element + + + + &reftitle.description; + + integerSimpleXMLElement::count + + + + This method counts the number of children of an element. + + + + + &reftitle.returnvalues; + + Returns the number of elements of an element. + + + + + &reftitle.examples; + + + Counting the number of children + + + + + + + + + + + + + + + +EOF; + +$elem = new SimpleXMLElement($xml); + +foreach ($elem as $person) { + printf("%s has got %d children.\n", $person['name'], $person->count()); +} +?> +]]> + + &example.outputs; + + + + + + + + + &reftitle.seealso; + + + SimpleXMLElement::children + + + + + + + diff --git a/reference/simplexml/versions.xml b/reference/simplexml/versions.xml index 09b8c6f022..a1f1a1942f 100644 --- a/reference/simplexml/versions.xml +++ b/reference/simplexml/versions.xml @@ -14,6 +14,7 @@ + @@ -49,4 +50,4 @@ End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 ---> \ No newline at end of file +-->