I enter such data into an array

$this->chests[$player->getName()] = new ChestMenu( $this, $player, $array, "particles", "§bВыберите режим" ); 

Checking

 if (!is_object($this->chests[$player->getName()])) return; 

Climbs Notice:

Notice: Undefined index: Matrix51 in /root/server/bridge/plugins/TheBridgeAPI/src/truexackep/API.php on line 148

thank

  • So in the array $this->chests there is no element with the index Matrix51 . Do var_dump and see what variables you have - robertobadjio
  • I want to check whether it is or not. - Anonim Anonim

1 answer 1

Add this check here:

 isset($this->chests[$player->getName()]) 
  • isset does not work on an object ... - Anonim Anonim
  • in my case, this is a ChestMenu object - Anonim Anonim
  • you need to check if there is a key like this in the array, and then check the object there or something else. - xoma
  • one
    $this->chests you have an array, check through isset - robertobadjio