Changing the SplFixedArray size after declaration

As we are defining the array size at the beginning, we may require changing the size later on. In order to do that, we have to use the setSize() method of the SplFixedArray class. An example is shown as follows:

$items = 5; 
$array = new SplFixedArray($items);
for ($i = 0; $i < $items; $i++) {
$array[$i] = $i * 10;
}

$array->setSize(10);
$array[7] = 100;
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset