PHP | ArrayObject count() Function
The ArrayObject::count() function is an inbuilt function in PHP which is used to get the number of public properties in the ArrayObject.
Syntax:
int ArrayObject::count( void )
Parameters: This function does not accept any parameters.
Return Value: This function returns the number of public properties in the ArrayObject.
Below programs illustrate the ArrayObject::count() function in PHP:
Program 1:
<?php // PHP program to illustrate the // ArrayObject::count() function // Declare an array and convert it // into array object $arrObject = new ArrayObject( array ( 'Geeks' , 'for' , 'Geeks' ) ); // Use ArrayObject::count() function // to count the number of public // properties in the ArrayObject $count = $arrObject -> count (); print_r( $count ); ?> |
3
Program 2:
<?php // PHP program to illustrate the // ArrayObject::count() function // Declare an associative array $arr = array ( "a" => "Welcome" , "b" => "to" , "c" => "GeeksforGeeks" ); // Create into array object $arrObject = new ArrayObject( $arr ); // Use ArrayObject::count() function // to count the number of public // properties in the ArrayObject $count = $arrObject -> count (); print_r( $count ); ?> |
3
Reference: https://www.php.net/manual/en/arrayobject.count.php
Recommended Posts:
- ArrayObject asort() Function in PHP
- ArrayObject getIteratorClass() Function in PHP
- ArrayObject ksort() Function in PHP
- ArrayObject natcasesort() Function in PHP
- ArrayObject offsetUnset() Function in PHP
- ArrayObject append() function in PHP
- ArrayObject offsetSet() Function in PHP
- ArrayObject getIterator() Function in PHP
- ArrayObject offsetGet() Function in PHP
- PHP | ArrayObject setIteratorClass() Function
- ArrayObject natsort() Function in PHP
- PHP | ArrayObject setFlags() Function
- ArrayObject getArrayCopy() Function in PHP
- PHP | ArrayObject getFlags() Function
- PHP | ArrayObject unserialize() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.