Let's say there is an array with 5 entries that I can grab by using $array[1] , $array[2], $array[3] and so on.
I assigned variables to these arrays such as:
Code: Select all
$new_value1 = $arrayї1];
$new_value2 = $arrayї2];
$new_value3 = $arrayї3];
$new_value4 = $arrayї4];
$new_value5 = $arrayї5];From the above example you can see that only the number at the end of the variable and the corresponding array number changes.
I would like to replace the 5 lines of code with just one with the help of "range" function so that the code looks like:
Code: Select all
$range = range(1, 5);How can I do this? I am still quite new to arrays but I am learning
Thanks!
Tomas