How can references be used effectively when unsetting nested array elements in PHP?

When unsetting nested array elements in PHP, references can be used effectively by passing the reference to the nested array element to the unset function. This ensures that the element is unset from the original array rather than just from a copy of the array. By using references, the changes made to the nested array will be reflected in the original array.

$array = [
    'foo' => [
        'bar' => 'baz'
    ]
];

$nestedElement =& $array['foo']['bar'];
unset($nestedElement);

print_r($array);