I’m going to show you a couple cool tricks you can use for defining arrays like this.
Notice that this type of array uses a consecutive list of integers. When using strings or nonconsecutive integers, these tricks won’t work, but when using similar lists these tricks are great.
The first trick is to skip defining the array key. When you begin defining the array with the short syntax and skip the "key" => part (using only a list of values), you get an array with integer indices starting at 0. For example, say you did this:
$testarray = array('a','b','c','d','e');
You get an array with these elements:
$testarray='a'; $testarray='b'; $testarray='c'; $testarray='d'; $testarray='e'; ...