Array objectivity check
True if array is objective, False if array is sequential or have only number keys

@param $arr
@return bool
8620
protected static function isArrayObject($arr)
    {
        foreach(array_keys($arr) as $key) {
            if (!is_int($key)) {
                return true;
            }
        }

        return false;
    }
750944
public static function isAssoc(array $arr)
    {
        return (is_array($arr) && (!count($arr) || count(array_filter(array_keys($arr),'is_string')) == count($arr)));
    }
170694
private static boolean contains(Object[] arr, Object obj) {
	for (Object o : arr) {
	    if (o.equals(obj)) return true;
	}
	return false;
    }
1066174
public function checkNameValues($arr) {
        $result = true;
        // TODO: Perhaps, add support for reserved words

        // Check the name only contains valid chars
        if ($arr) {
            foreach($arr as $element) {
                if (!$element->checkName()) {
                    $result = false;
                }
            }
        }
        // Check there aren't duplicate names
        if ($arr) {
            $existing_fields = array();
            foreach($arr as $element) {
                if (in_array($element->getName(), $existing_fields)) {
                    debugging('Object ' . $element->getName() . ' is duplicated!', DEBUG_DEVELOPER);
                    $result = false;
                }
                $existing_fields[] = $element->getName();
            }
        }
        return $result;
    }
1094269
private function checkKey(array $arr)
    {
        foreach ($arr as $key => $val) {
            // 下标只允许包含字母、数字、下划线
            if (preg_match("/[^a-z0-9_]/i", $key)) {
                throw new \Exception('“' . $key . '”配置下标只允许包含字母、数字、下划线');
            }
            
            if (is_array($val)) {
                $this->checkKey($val);
            }
        }
    }
522978
public static function array_type(&$arr=null) {
		if (! \is_array($arr) || ! \count($arr)) {
			return false;
		}

		$keys = \array_keys($arr);
		if (\range(0, \count($keys) - 1) === $keys) {
			return 'sequential';
		}
		elseif (\count($keys) === \count(\array_filter($keys, 'is_numeric'))) {
			return 'indexed';
		}
		else {
			return 'associative';
		}
	}
376203
public static function is_array( $possibleArray, $_ = null )
    {
        foreach ( func_get_args() as $_argument )
        {
            if ( !is_array( $_argument ) )
            {
                return false;
            }
        }

        return true;
    }
1369590
public static function array_pop_rand(array &$arr) {
		$length = \count($arr);

		if (! $length) {
			return false;
		}

		// Nothing random about an array with one thing.
		if (1 === $length) {
			return static::array_pop_top($arr);
		}

		$keys = \array_keys($arr);
		$index = static::random_int(0, $length - 1);

		return $arr[$keys[$index]];
	}
1207639
public static function even(array $arr, callable $callback): bool
    {
        if (count($arr) === 0) {
            return false;
        }

        foreach ($arr as $index => $value) {
            if ($callback($value, $index) !== true) { // false, 0 or null
                return false;
            }
        }

        return true;
    }
839589
public static function is_assoc($arr)
	{
		if ( ! is_array($arr))
		{
			throw new \InvalidArgumentException('The parameter must be an array.');
		}

		$counter = 0;
		foreach ($arr as $key => $unused)
		{
			if ( ! is_int($key) or $key !== $counter++)
			{
				return true;
			}
		}
		return false;
	}
160488
public function fromArray($arr)
    {
        if (!empty($arr)) {
            // Iterate over each element in array
            foreach ($arr as $k => $v) {
                // If the value is an array, it means, it is an object after conversion
                if (is_array($v)) {
                    // Determine the class of the object
                    if (($clazz = ReflectionUtil::getPropertyClass(get_class($this), $k)) != null) {
                        // If the value is an associative array, it means, its an object. Just make recursive call to it.
                        if (empty($v)) {
                            if (ReflectionUtil::isPropertyClassArray(get_class($this), $k)) {
                                // It means, it is an array of objects.
                                $this->assignValue($k, array());
                                continue;
                            }
                            $o = new $clazz();
                            //$arr = array();
                            $this->assignValue($k, $o);
                        } elseif (ArrayUtil::isAssocArray($v)) {
                            /** @var BlockCypherModel $o */
                            $o = new $clazz();
                            $o->fromArray($v);
                            $this->assignValue($k, $o);
                        } else {
                            // Else, value is an array of object/data
                            $arr = array();
                            // Iterate through each element in that array.
                            foreach ($v as $nk => $nv) {
                                if (is_array($nv)) {
                                    //BlockCypherLoggingManager::getInstance()->debug("new instance of class: $clazz");
                                    if (!class_exists($clazz)) {
                                        BlockCypherLoggingManager::getInstance()->error("Class not found: $clazz");
                                    } else {
                                        try {
                                            $o = new $clazz();
                                            $o->fromArray($nv);
                                            $arr[$nk] = $o;
                                        } catch (\Exception $e) {
                                            BlockCypherLoggingManager::getInstance()->error($e->getMessage());
                                        }
                                    }
                                } else {
                                    $arr[$nk] = $nv;
                                }
                            }
                            $this->assignValue($k, $arr);
                        }
                    } else {
                        $this->assignValue($k, $v);
                    }
                } else {
                    $this->assignValue($k, $v);
                }
            }
        }
        return $this;
    }
6161
public static function createFromArray(array $arr)
    {
        $ret = new Url;
        $keys = ['scheme','user','pass','host','port','path','query','fragment'];
        foreach ($keys as $key) {
            if (array_key_exists($key, $arr)) {
                $fn = 'set'.ucfirst($key);
                call_user_func([$ret, $fn], $arr[$key]);
            }
        }
        return $ret;
    }
1252040
public static function isList(array $array): bool
	{
		$count = count($array);

		$range = $count
			? range(0, $count - 1)
			: [];

		$keys = array_keys($array);

		return $keys === $range;
	}
1029405
public static function array_compare(&$arr1, &$arr2) {
		// Obviously bad data.
		if (! \is_array($arr1) || ! \is_array($arr2)) {
			return false;
		}

		$length = \count($arr1);

		// Length mismatch.
		if (\count($arr2) !== $length) {
			return false;
		}

		// Different keys, we don't need to check further.
		if (\count(\array_intersect_key($arr1, $arr2)) !== $length) {
			return false;
		}

		// We will ignore keys for non-associative arrays.
		if (
			(cast::array_type($arr1) !== 'associative') &&
			(cast::array_type($arr2) !== 'associative')
		) {
			return \count(\array_intersect($arr1, $arr2)) === $length;
		}

		// Check each item.
		foreach ($arr1 as $k=>$v) {
			if (! isset($arr2[$k])) {
				return false;
			}

			// Recursive?
			if (\is_array($arr1[$k]) && \is_array($arr2[$k])) {
				if (! static::array_compare($arr1[$k], $arr2[$k])) {
					return false;
				}
			}
			elseif ($arr1[$k] !== $arr2[$k]) {
				return false;
			}
		}

		return true;
	}
217635
function isArrayOfArray(o) {
    if(isArray(o)) {
      if(o.length > 0) {
        if(isArray(o[0])) {
          return true;
        }
      }
    }
    return false;
  }
890764
function Read($arr)
	{
		foreach (get_object_vars($this) as $prop)
		{
			if (array_key_exists($prop,$arr))
			{
				$this->$prop = $arr[$prop];
			}
		}
	}
501728
private function isAssocArray($item): bool
    {
        if (!is_array($item)) {
            // Is not an array at all
            return false;
        }

        if ($item === []) {
            // Treat empty array as Sequential
            return false;
        }

        // Check if keys are equal to sequence of 0 .. n-1
        return array_keys($item) !== range(0, count($item) - 1);
    }