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

array_fill() public static method

Creates a new array filled with a specified value.
Thrown if is not positive.
public static array_fill ( int startIndex, int count, PhpValue value ) : PhpArray
startIndex int The value of the key of the first item in the array.
count int The number of items in the array.
value Pchp.Core.PhpValue The value copied to all items in the array.
return Pchp.Core.PhpArray
		public static PhpArray array_fill(int startIndex, int count, PhpValue value)
        {
            if (count <= 0)
            {
                // TODO: PhpException.InvalidArgument("count", LibResources.GetString("arg:negative_or_zero"));
                return null;
            }

            PhpArray result = new PhpArray(count, 0);
            int last = startIndex + count;
            for (int i = startIndex; i < last; i++)
                result.Add(i, value);

            // makes deep copies of all added items:
            //result.InplaceCopyOnReturn = true;
            return result;
        }