Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP count() Function

PHP count() Function

PHP SimpleXML Reference Manual PHP SimpleXML Reference Manual

Example

Count the child nodes of the car node:

XML; $elem=new SimpleXMLElement($xml); foreach ($elem as $car) { printf("%s has %d children.
", $car['name'], $car->count()); } ?>

Run Example »


Definition and Usage

The count() function counts the number of child nodes of a specified node.


Syntax

count();

Technical Details

Return Value: Returns the number of child nodes of an element.
PHP Version: 5.3+

PHP SimpleXML Reference Manual PHP SimpleXML Reference Manual