$array = ["world", "is", "beautiful"]; array_unshift($array, "hello"); print_r($array); // output: Array ( [0] => hello [1] => world [2] => is [3] => beautiful )
$array = ["world", "is", "beautiful"]; $elements = ["hello", "my", "friend"]; array_unshift($array, ...$elements); print_r($array); // output: Array ( [0] => hello [1] => my [2] => friend [3] => world [4] => is [5] => beautiful )This function is part of the PHP core library and does not require any additional package library.