In PHP, what function can be used to add a null element at the beginning of an array and adjust the indexing accordingly?

To add a null element at the beginning of an array in PHP and adjust the indexing accordingly, you can use the array_unshift() function. This function adds one or more elements to the beginning of an array, shifting the existing elements to higher indexes. By adding a null element at the start, the indexing of the array will be adjusted automatically.

// Create an array
$array = [1, 2, 3, 4, 5];

// Add a null element at the beginning of the array
array_unshift($array, null);

// Display the modified array
print_r($array);