I have an error of (Undefined array key)

Discussion in 'Help' started by RdxMALPIGHIT, Oct 24, 2021.

  1. RdxMALPIGHIT

    RdxMALPIGHIT Creeper

    Messages:
    1
    GitHub:
    RaidoxxADM
    Line 317 - return $this->config->get('members')[$player->getName()];




    ErrorException: "Undefined array key "Alvarobr022"" (EXCEPTION) in "plugins/IHFactionsPremiun_v0.0.1-SNAPSHOT/src/ihfactionspremiun/IHFactionsPremiunInstance" at line 317
     
  2. Tobias14

    Tobias14 Spider

    Messages:
    6
    GitHub:
    tobias-2006
    You should check if the array key exists..
    like
    PHP:
    $members $this->config->get('members', []);
    if(isset(
    $members[$player->getName()])) {
        
    $member $members[$player->getName()];
        
    // Do something with $member
    }
     
    minijaham likes this.
  3. Primus

    Primus Zombie Pigman

    Messages:
    707
    PHP:
    return $this->config->getNested('members.' $player->getName());
     
    NTT, cosmicnebula and minijaham like this.

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.