What is the best practice for storing a complete result list in an array in PHP for further use?

When storing a complete result list in an array in PHP for further use, it is best practice to use a loop to fetch each row of the result set and store it in the array. This ensures that all the data is captured and can be easily accessed later on. Additionally, using an associative array where each row is stored as an associative array with column names as keys can make it easier to work with the data.

// Assuming $result is the result set obtained from a database query
$result_list = array();

while ($row = mysqli_fetch_assoc($result)) {
    $result_list[] = $row;
}

// Now $result_list contains all the rows from the result set in an array for further use