in Php

SplFixedArray & Array in PHP

Simply an array is a variable which hold more than one value at a time. An example would be :

Let’s say we have a list of references sites. Storing them in a variables could look something like this.

We only have 3 right now. Talk about the massacre when we have 200 or more. This is where array comes in as a solution.

An single array can hold many values and values can be access using an index number which starts form 0.

There are 3 types of arrays. Indexed arrays ( have a numeric index ), Associative arrays (have named keys) and Multidimensional arrays ( contains one or more arrays).

The SplFixedArray class provides the main functionalities of array. The main differences between a SplFixedArray and a normal PHP array is that the SplFixedArray is of fixed length and allows only integers within the range as indexes. The advantage is that it allows a faster array implementation.

We can say the memory footprint of SplFixedArray is smaller but only noticeable with a large amount of array elements. Technically SplFixedArray is an instance of a class which cause small arrays consume more memory if implemented by SplFixedArray.

Hope this help you understand the both term. Happy Coding 🙂