PHP SPL FixedArray example

// Initialize the array with a fixed length
$array = new SplFixedArray(5);

$array[1] = 2;
$array[4] = “foo”;

// Increase the size of the array
$array->setSize(10);

$array[9] = “asdf”;

// Shrink the array to a size of 2
$array->setSize(2);

Leave a Reply

You must be logged in to post a comment.