What is the best practice for handling duplicate arrays in PHP when fetching data from a database?

When fetching data from a database in PHP, duplicate arrays may occur if the same data is retrieved multiple times. To handle this issue, you can use the `array_unique()` function to remove duplicate arrays from the result set.

// Fetch data from the database
$query = "SELECT * FROM your_table";
$result = mysqli_query($connection, $query);

// Store the results in an array
$data = [];
while ($row = mysqli_fetch_assoc($result)) {
    $data[] = $row;
}

// Remove duplicate arrays
$data = array_map("unserialize", array_unique(array_map("serialize", $data)));

// Now $data contains unique arrays