What is the syntax for removing a specific element in an array in PHP?

To remove a specific element from an array in PHP, you can use the unset() function followed by the index of the element you want to remove. This will remove the element from the array and reindex the remaining elements. Make sure to check if the element exists in the array before attempting to remove it to avoid errors.

// Example array
$fruits = array("apple", "banana", "orange", "grape");

// Remove the element at index 2 (orange)
if (isset($fruits[2])) {
    unset($fruits[2]);
}

// Output the modified array
print_r($fruits);