Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Array help

Comments in 'Plugin Development' started by TryoneLegendZzz, Apr 27, 2016.

  1. TryoneLegendZzz
    Offline

    TryoneLegendZzz Active Member

    Joined:
    May 31, 2015
    Posts:
    201
    Minecraft User:
    SavionLegendZzz
    I am trying to put my config array into an array in my plugin but it wont accept it i tried to print it to console but it said "Array to string conversion" and help? Here i my code:
    PHP:
    $cfg $this->pconfig->getAll();
            foreach(
    $this->pconfig->get("Particles") as $p){
                
    $level $cfg["Particles"][$p]["level"];
                
    $this->particles[$p] = array("level" => $level,"id" => $cfg["Particles"][$p]["id"],"text" => $cfg["Particles"][$p]["text"]);
                
    $this->getLogger()->info("Info: ".var_dump($this->particles));
            }
    Config:
    Code:
    ---
    Particles:
      Ye:
        text: test
        level: world
        id: 1
    ...
    
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    You are trying to display an array as a string
    AndrewBit likes this.
  3. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    'var_dump' is void function.
    PHP:
    foreach($this->particles as $particle){
        
    $this->getLogger()->info($particle['level']);
        
    $this->getLogger()->info($particle['id']);
        
    # And so on...
    }
    minebuilder0110 likes this.
  4. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Or just use implode()
  5. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Not beautiful :p
  6. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Well, depends on the situation. For example when sending the player a message with all players in an array. :D
    Vaivez66 likes this.
  7. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Agree, but it doesn't apply to this situation

Share This Page

Advertisement