PHP Version
4+
$array = [1, 2, 3];

// Add a single element to the beginning of the array.
array_unshift($array, 4);
print_r($array);
/*
Output:
    Array
    (
        [0] => 4
        [1] => 1
        [2] => 2
        [3] => 3
    )
*/

// Add multiple elements to the beginning of the array.
array_unshift($array, 5, 6, 7);
print_r($array);
/*
Output:
    Array
    (
        [0] => 5
        [1] => 6
        [2] => 7
        [3] => 4
        [4] => 1
        [5] => 2
        [6] => 3
    )
*/
array_unshift(array &$array, mixed $value1 [, mixed $value2 [, mixed $... ]]): int
$array = [1, 2, 3];

// Add an element to the beginning of the array and store the return value.
$total_elements = array_unshift($array, 4);
print_r($array);
/*
Output:
    Array
    (
        [0] => 4
        [1] => 1
        [2] => 2
        [3] => 3
    )
*/

echo 'Total number of elements in the array: ' . $total_elements;
// Output: Total number of elements in the array: 4
$fruits = ['apple', 'banana', 'cherry'];

// Add elements to the beginning of the array
array_unshift($fruits, 'date', 'elderberry');

// Display the array contents
print_r($fruits);
/*
Output:
    Array
    (
        [0] => date
        [1] => elderberry
        [2] => apple
        [3] => banana
        [4] => cherry
    )
*/
$numbers = [1, 2, 3, 4, 5];
$reversed_numbers = [];

foreach ($numbers as $number) {
    array_unshift($reversed_numbers, $number);
}

print_r($reversed_numbers);
/*
Output:
    Array
    (
        [0] => 5
        [1] => 4
        [2] => 3
        [3] => 2
        [4] => 1
    )
*/