public static function isSequential($value, $strict=false)
    {

        if ($value === []) {
            return true;
        }

        if (!is_object($value) && !is_array($value)) {
            return false;
        }

        $hasArrayAccess = is_array($value) || $value instanceof ArrayAccess;
        $isTraversable = is_array($value) || $value instanceof Traversable;

        // An object which you cant traverse shouldnt be sequential
        if (!$isTraversable) {
            return false;
        }

        if ($strict && $hasArrayAccess) {
            $keys = static::keys($value);
            return $keys === range(0, count($keys) - 1);
        }

        foreach ($value as $key=>$unused) {
            return $key === 0;
        }

        // Traversable and empty
        return true;

    }
public static function isSequential($value, $strict=false)
    {

        if ($value === []) {
            return true;
        }

        if (!is_object($value) && !is_array($value)) {
            return false;
        }

        $hasArrayAccess = is_array($value) || $value instanceof ArrayAccess;
        $isTraversable = is_array($value) || $value instanceof Traversable;

        // An object which you cant traverse shouldnt be sequential
        if (!$isTraversable) {
            return false;
        }

        if ($strict && $hasArrayAccess) {
            $keys = static::keys($value);
            return $keys === range(0, count($keys) - 1);
        }

        foreach ($value as $key=>$unused) {
            return $key === 0;
        }

        // Traversable and empty
        return true;

    }
public static function isSequential ( $ value , $ strict = false ) { if ( $ value === [ ] ) { return true ; } if ( ! is_object ( $ value ) && ! is_array ( $ value ) ) { return false ; } $ hasArrayAccess = is_array ( $ value ) || $ value instanceof ArrayAccess ; $ isTraversable = is_array ( $ value ) || $ value instanceof Traversable ; // An object which you cant traverse shouldnt be sequential if ( ! $ isTraversable ) { return false ; } if ( $ strict && $ hasArrayAccess ) { $ keys = static :: keys ( $ value ) ; return $ keys === range ( 0 , count ( $ keys ) - 1 ) ; } foreach ( $ value as $ key => $ unused ) { return $ key === 0 ; } // Traversable and empty return true ; }
Return true if the passed object or array is a sequence

@param mixed $value
@param bool  $strict (default:true)

@return bool
Return true if the passed object or array is a sequence