I know how to insert it to the end by:
$arr[] = $item;
But how to insert it to the beginning?
Use array_unshift() to insert the first element in an array.
User array_shift() to removes the first element of an array.