4
What are the advantages of using Splfixedarray instead of an array?
What are the advantages of fixing a value to an "array" (in PHP) ?
Example with array
:
$arr = array();
$arr[0] = 'Stack';
$arr[1] = 'Overflow';
$arr[2] = 'blablabla';
Example withSplFixedArray
$arr = new SplFixedArray(2);
$arr[0] = 'Stack';
$arr[1] = 'Overflow';
$arr[2] = 'blablabla'; // RunTimeException: Index invalid or out of range
"a value for an array" do you mean a size? If that’s the advantage it takes up exactly the memory space you want.
– Jorge B.
Splfixedarray is faster than matrices, and has a lower memory consumption.
– Williams
Why?????????
– Wallace Maxters
Because tests have already been done, and more tests, from one look in this article, will know why!!!
– Williams