my question is easy
is that … :
$arr = array(1, 2, 3, 4, 5, ..., x); //x is a huge number for the theory
…faster, lower or is it the same speed than :
$arr[] = 1;
$arr[] = 2;
$arr[] = 3;
$arr[] = 4;
$arr[] = 5;
...
$arr[] = x;
?
I think the second way of coding is easy to alter especially if there are multi-dim arrays.
But is this one altering the speed of processing ?
By rough testing, the second method is twice as slow as the first one but unless you are using a very large array (100,000+ elements) or initializing the array a lot of times (1000s of times per second), the difference is negligible.
For syntactic purposes, refer to Berk’s answer.