php - create array in while loop - can't figure it out

Joined
12 Feb 2006
Posts
17,313
Location
Surrey
why isn't the below working? the array is being created and returned, however it's just the latest while loop that gets returned. i've tried $timeoff .= array.... but that messes it up. how would i add to the array without resetting it?

PHP:
$timeoff = array();

   while($row = mysqli_fetch_array($result_stafftimes_timeoff)) {
   
$offId =$row['offId'];
$location =$row['location'];
$startdate =$row['startdate'];   
$enddate =$row['enddate'];   
$reason =$row['reason'];   

$timeoff = array
  (
  array($startdate,$enddate,$reason, $location),

  );
  


}

  return($timeoff);
}
 
Back
Top Bottom