array does not work

Discussion in 'Development' started by iCirgio, Aug 3, 2019.

  1. iCirgio

    iCirgio Slime

    Messages:
    88
    GitHub:
    lolnova
    im trying to make a permissions plugin and i have my config file saved like this with rank player and voyager
    Error: Invalid args supplied for foreach()
    PHP:
    ---
    player:
    core.testpermission
    core.testpermission
    voyager
    :
    core.testpermission
    core.testpermission
    ...
    why is this not working?
    PHP:
             $config = new Config(Core::getInstance()->getDataFolder() . "Permissions.yml"Config::YAML);
             
    $oldperms $config->get($this->getRank()); //getRank() returns players rank
             
    foreach($oldperms as $oldperm){
                 
    $this->addAttachment(Core::getInstance(), $oldpermfalse);
             }
     
  2. HeyDeniis_

    HeyDeniis_ Spider Jockey

    Messages:
    45
    PHP:
    $data = new Config(Core::getInstance()->getDataFolder()."Permissions.yml"Config::YAML, []);
    $rank $this->getRank();
    foreach(
    $data->get($rank) as $perm){
    ///......
    }
    //Verify If $this->getRank() returns real rank of player ..
    I/PHP]
     
  3. KielKing

    KielKing Zombie

    Messages:
    271
    GitHub:
    kielking
    there is a couple of things you need to account

    the config has not been previously set up and will be emtpy
    the path you provided may not be the location of the config
    getRank() does not properly return the string you want
    your config does not have the rank set up
     
    OnTheVerge and HimbeersaftLP like this.
  4. Deniel

    Deniel Spider Jockey

    Messages:
    30
    GitHub:
    DenielWorld
    $oldperms does not return an array to be foreached?
     

Share This Page

  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.