What are some common pitfalls to avoid when working with arrays in PHP, especially when dealing with duplicate values?

One common pitfall when working with arrays in PHP, especially when dealing with duplicate values, is accidentally overwriting existing values when using array functions like `array_push` or `array_merge`. To avoid this, you can check for duplicate values before adding them to the array using functions like `in_array` or `array_search`.

// Avoid overwriting existing values when adding to an array
$myArray = [1, 2, 3, 4];
$newValue = 3;

if (!in_array($newValue, $myArray)) {
    $myArray[] = $newValue;
}

print_r($myArray);