1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Solved How to foreach() every single world in the server?

Discussion in 'Development' started by EndermannbugZJFC, May 25, 2020.

  1. EndermannbugZJFC

    EndermannbugZJFC Slime

    Messages:
    84
    GitHub:
    endermanbugzjfc
    Can anyone tell me the proper way to foreach() every single world in the server to do different things? Because getLevels() from the server class will return a Level instance and not an array of every levels in the server.
     
  2. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    PHP:
    foreach (array_map(function (Level $level) {
        return 
    $level->getName();
    }, 
    $this->getServer()->getLevels()) as $levelName) {
                
    }
     
  3. EndermannbugZJFC

    EndermannbugZJFC Slime

    Messages:
    84
    GitHub:
    endermanbugzjfc
    tysm
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.