How can I modify this code for the second array’s values to start with “value 4” and end with “value 6”? Basically the first parameter of range() should be dynamic but I’m not sure if that’s possible?
for($i = 1; $i <= 2; $i++)
{
$rows[] = array_map(function($n) {
return "value " . $n;
}, range(1, 3));
}
print_r($rows) should be
Array
(
[0] => Array
(
[0] => value 1
[1] => value 2
[2] => value 3
)
[1] => Array
(
[0] => value 4
[1] => value 5
[2] => value 6
)
)
I’ve restructured your code a little. This is my solution: