array_unshift
is using for inserting one or many values at the beginning of an array. Now I have an array-
$data = [1, 3, 4];
Another array is needed to insert at the beginning of the $data
array.
$values = [5, 6];
Here I want to insert the values 5, 6
at the beginning of the $data
array, and the resulting $data
would be-
$data = [5, 6, 1, 3, 4];
Note: I know there is a way like array_unshift($data, ...$values);
but this is working from php7.3.x
AFAIK. I need to do it below php7.3
.
Is there any way to do this without looping the $values
array in the reverse order?