Pchp.Library.Arrays.array_unshift C# (CSharp) Method

array_unshift() public static method

Inserts specified items before the first item of an array and reindex integer keys starting from zero.
public static array_unshift ( PhpArray array ) : int
array Pchp.Core.PhpArray The array to be unshifted.
return int
        public static int array_unshift(PhpArray array, params PhpValue[] vars)
        {
            if (array == null)
            {
                //PhpException.ReferenceNull("array");
                //return 0;
                throw new ArgumentNullException();
            }

            // reindexes integer keys starting from the number of items to be prepended:
            array.ReindexIntegers(vars.Length);

            // prepends items indexing keys from 0 to the number of items - 1:
            for (int i = vars.Length - 1; i >= 0; i--)
            {
                array.Prepend(i, vars[i]);
            }

            return array.Count;
        }