How can the is_unique function be optimized for better performance when checking for existing keys in PHP?
When checking for existing keys in PHP, the is_unique function can be optimized for better performance by using the in_array function instead of looping through the array to check for duplicates. This will reduce the time complexity of the function and improve its efficiency.
function is_unique($array, $key) {
return !in_array($key, $array);
}