function groups() {
$merge = array();
$r = 65;
while ($r <= 69) {
$b = bookings($r);
$merge = array_merge($merge, $b);
$r++;
}
return $merge;
}
PHP - push arrays into array?
-
15-07-2023 - |
質問
I have created a function that loops through another function, and the other function returns an array. If I loop through the other function four times, I will get four arrays returned but only one per loop. I would like to merge these four arrays into one array inside my new function.
This is the new function:
function groups() {
$b = array();
$r = 65;
while ($r <= 69) {
$b = bookings($r);
$merge = array_merge($b);
$r++;
}
return $merge;
}
This function only returns the bookings for group 69, but I want to get the bookings for 65, 66, 67, 68 and 69. Please help! Sorry if something is confusing.
解決
他のヒント
You may try array_push() function
$b = array_push($b, $r);
所属していません StackOverflow