Hello,
I am trying to make a program for adding an element at the beginning of an array. I know it is possible with array_unshift. But, I want to create a function myself for serving the purpose. I tried a lot but no success. Please go through the below code and find out the wrong or post your own code.
Thanks.
<?php
function addstart($array,$v)
{
$s=$array[0];
for($i=0;$i<5;$i++)
{
$s=$array[i+1];
$array[i+1]=$array[i];$array[i]=$s;
}
$array[0]=$v;
print_r($array);
}
$x=888;
$arr=array(1,2,8,96,85);
addstart($arr,;
//print_r($arr);
?>