9951 explained code solutions for 126 technologies


phpHow to append an element to the beginning of array


$myarray = [1,2];
array_unshift($myarray, 'hatstand');ctrl + c
$myarray

the array to append new element to

array_unshift

will append given value (hatstand) to the beginning of given array ($myarr), array will be updated

hatstand

value to append to array