PHP | Ds\Vector count() Function Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report The Ds\Vector::count() function is an inbuilt function in PHP which is used to count the number of elements in the vector. Syntax: int public Ds\Vector::count( void ) Parameters: This function does not accepts any parameter. Return Value: This function returns the number of elements in the vector. Below programs illustrate the Ds\Vector::count() function in PHP: Program 1: PHP <?php // Declare a vector $arr1 = new \Ds\Vector([1, 2, 3, 4, 5, 6, 7, 8]); echo("Vector elements\n"); // Display the vector elements print_r($arr1); echo("Count vector elements: "); // Use count() function to count // elements in the vector echo(count($arr1)); ?> Output: Vector elements Ds\Vector Object ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 [7] => 8 ) Count vector elements: 8 Program 2: PHP <?php // Declare a vector $arr1 = new \Ds\Vector(["geeks", "for", "geeks"]); echo("Vector elements\n"); // Display the vector elements print_r($arr1); echo("Count vector elements: "); // Use count() function to count // elements in the vector echo(count($arr1)); ?> Output: Vector elements Ds\Vector Object ( [0] => geeks [1] => for [2] => geeks ) Count vector elements: 3 Reference: https://www.php.net/manual/en/ds-vector.count.php Comment More infoAdvertise with us Next Article PHP | Ds\Vector contains() Function B barykrg Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_vector Similar Reads PHP | Ds\Vector contains() Function The Ds\Vector::contains() function is an inbuilt function in PHP which is used to check the vector contains given value or not. Syntax: bool public Ds\Vector::contains( $values ) Parameters: This function accepts a single parameter $values which contains single/many values. Return Value: This functi 1 min read PHP | Ds\Vector contains() Function The Ds\Vector::contains() function is an inbuilt function in PHP which is used to check the vector contains given value or not. Syntax: bool public Ds\Vector::contains( $values ) Parameters: This function accepts a single parameter $values which contains single/many values. Return Value: This functi 1 min read PHP Ds\Set count() Function The Ds\Set::count() function of Ds\Set class in PHP is an inbuilt function which is used to count the number of values present in the Set. This is also referred to as the size of the Set instance. Syntax: int public Ds\Set::count() Parameters: This function does not accept any parameter. Return Valu 1 min read PHP Ds\Set count() Function The Ds\Set::count() function of Ds\Set class in PHP is an inbuilt function which is used to count the number of values present in the Set. This is also referred to as the size of the Set instance. Syntax: int public Ds\Set::count() Parameters: This function does not accept any parameter. Return Valu 1 min read PHP | Ds\Vector copy() Function The Ds\Vector::copy() function is an inbuilt function in PHP which is used to create a copy of given vector. Syntax: Ds\Vector public Ds\Vector::copy( void ) Parameters: This function does not accept any parameter. Return Value: This function returns a shallow copy of the vector. Below programs illu 2 min read PHP | Ds\Vector copy() Function The Ds\Vector::copy() function is an inbuilt function in PHP which is used to create a copy of given vector. Syntax: Ds\Vector public Ds\Vector::copy( void ) Parameters: This function does not accept any parameter. Return Value: This function returns a shallow copy of the vector. Below programs illu 2 min read Like