The SplFixedArray::setSize() function is an inbuilt function in PHP which is used to set the size of the array.
Syntax:
bool SplFixedArray::setSize( $size )
Parameters: This function accepts a single parameter $size which specifies the size of the array.
Return Value: This function returns true on success, false otherwise.
Below programs illustrate the SplFixedArray::setSize() function in PHP:
Program 1:
<?php
$gfg = new SplFixedArray(50);
echo $gfg ->getSize() . "\n" ;
$gfg ->setSize(110);
echo $gfg ->getSize() . "\n" ;
?>
|
Program 2:
<?php
$gfg1 = new SplFixedArray(0);
$gfg2 = new SplFixedArray(9);
$gfg3 = new SplFixedArray(100);
$gfg4 = new SplFixedArray(878);
echo $gfg1 ->getSize() . "\n" ;
echo $gfg2 ->getSize() . "\n" ;
echo $gfg3 ->getSize() . "\n" ;
echo $gfg4 ->getSize() . "\n" ;
$gfg1 ->setSize(100);
$gfg2 ->setSize(200);
echo $gfg1 ->getSize() . "\n" ;
echo $gfg2 ->getSize() . "\n" ;
?>
|
Output:
0
9
100
878
100
200
Reference: https://www.php.net/manual/en/splfixedarray.setsize.php
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks 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!