How can you prevent duplicate entries when merging arrays in PHP?
When merging arrays in PHP, duplicate entries may occur if both arrays contain the same values. To prevent this, you can merge the arrays and then use the array_unique() function to remove any duplicate values.
$array1 = [1, 2, 3];
$array2 = [3, 4, 5];
$mergedArray = array_merge($array1, $array2);
$uniqueArray = array_unique($mergedArray);
print_r($uniqueArray);