Thursday, May 28, 2026
HomeLanguagesPHP SplFixedArray getSize() Function

PHP SplFixedArray getSize() Function

The SplFixedArray::getSize() function is an inbuilt function in PHP which is used to get the size of the array.

Syntax:

int SplFixedArray::getSize()

Parameters: This function does not accept any parameter.

Return Value: This function returns the size of the array.

Below programs illustrate the SplFixedArray::getSize() function in PHP:

Program 1:




<?php
  
// Create a fixed array
$gfg = new SplFixedArray(15);
  
// Print Size of the array
echo $gfg->getSize();
  
?>


Output:

15

Program 2:




<?php
  
// Create some fixed size array
$gfg1 = new SplFixedArray(0);
$gfg2 = new SplFixedArray(9);
$gfg3 = new SplFixedArray(100);
$gfg4 = new SplFixedArray(878);
  
// Print Size of the array
echo $gfg1->getSize() . "\n";
echo $gfg2->getSize() . "\n";
echo $gfg3->getSize() . "\n";
echo $gfg4->getSize() . "\n";
  
// Set array size
$gfg1->setSize(100);
$gfg2->setSize(200);
  
// Print size after set
echo $gfg1->getSize() . "\n";
echo $gfg2->getSize() . "\n";
?>


Output:

0
9
100
878
100
200

Reference:https://www.php.net/manual/en/splfixedarray.getsize.php

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32514 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6892 POSTS0 COMMENTS
Nicole Veronica
12012 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12107 POSTS0 COMMENTS
Shaida Kate Naidoo
7016 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6975 POSTS0 COMMENTS
Umr Jansen
6963 POSTS0 COMMENTS