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

array_combine() public static method

Creates an array using one array for its keys and the second for its values.
keys and values should have the same length (zero is adminssible - an empty array is returned). Keys are converted using PHP.Core.Convert.ObjectToArrayKey before hashed to resulting array. If more keys has the same value after conversion the last one is used. If a key is not a legal array key it is skipped. Doesn't dereference PHP references.
or is a null reference. and has different length.
public static array_combine ( PhpArray keys, PhpArray values ) : PhpArray
keys Pchp.Core.PhpArray The keys of resulting array.
values Pchp.Core.PhpArray The values of resulting array.
return Pchp.Core.PhpArray
        public static PhpArray array_combine(PhpArray keys, PhpArray values)
        {
            if (keys == null)
            {
                //PhpException.ArgumentNull("keys");
                //return null;
                throw new ArgumentNullException(nameof(keys));
            }

            if (values == null)
            {
                //PhpException.ArgumentNull("values");
                //return null;
                throw new ArgumentNullException(nameof(values));
            }

            if (keys.Count != values.Count)
            {
                //PhpException.Throw(PhpError.Warning, CoreResources.GetString("lengths_are_different", "keys", "values"));
                //return null;
                throw new ArgumentException();
            }

            IntStringKey key;

            PhpArray result = new PhpArray();
            var k_iterator = keys.GetFastEnumerator();
            var v_iterator = values.GetFastEnumerator();
            while (k_iterator.MoveNext())
            {
                v_iterator.MoveNext();

                // invalid keys are skipped, values are not dereferenced:
                if (Core.Convert.TryToIntStringKey(k_iterator.CurrentValue, out key))
                {
                    result[key] = v_iterator.CurrentValue;
                }
            }

            // result is inplace deeply copied on return to PHP code:
            //result.InplaceCopyOnReturn = true;
            return result;
        }