What are the advantages of using mysqli_result::fetch_assoc over mysqli_result::fetch_array(MYSQLI_BOTH) in PHP?

When using mysqli_result::fetch_array(MYSQLI_BOTH), the returned array will contain both numeric and associative keys for each row of data retrieved from the database. This can lead to potential confusion and inefficiency when accessing the data. Using mysqli_result::fetch_assoc, on the other hand, returns an array with only associative keys, making it easier to work with the data and improving code readability.

// Using mysqli_result::fetch_assoc to retrieve data from a MySQL database
$query = "SELECT * FROM table";
$result = $mysqli->query($query);

while ($row = $result->fetch_assoc()) {
    // Access data using associative keys
    echo $row['column_name'] . "<br>";
}