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

How do I get items of an array inside an array..?

Comments in 'Plugin Development' started by XFuryMCPE, Mar 4, 2016.

  1. XFuryMCPE
    Offline

    XFuryMCPE Active Member Plugin Developer

    Joined:
    Jun 19, 2015
    Posts:
    137
    Plugins:
    2
    Minecraft User:
    XFuriousMC
    So I have an array setup sorta like this:

    PHP:
    foreach($this->plugin->getServer()->getOnlinePlayers() as $p){
     
    $this->plugin->array["players"] = $p->getName();
    }
    How would I, for example, get a player named Joe from $array["players"], I want to check if his name is in the "players" part. And how would I unset only 'Joe'? I hope I explained well enough.
  2. applqpak
    Offline

    applqpak Active Member Plugin Developer

    Joined:
    Dec 16, 2015
    Posts:
    284
    Plugins:
    1
    Minecraft User:
    applqpak
    Sorry, I don't fully understand what you're saying.
  3. Vaivez66
    Offline

    Vaivez66 Notable Member Plugin Developer

    Joined:
    Jun 10, 2015
    Posts:
    402
    Plugins:
    2
    PHP:
    if(in_array('Joe'$array['players'])){ // Check if Joe is exist
        
    $search array_search('Joe'$array['players']); // Get the key of Joe
        
    unset($array['players'][$search]); // Unset the value of that key
    }
    I think it's something like this. Sorry if i had some mistakes :D
    applqpak likes this.
  4. XFuryMCPE
    Offline

    XFuryMCPE Active Member Plugin Developer

    Joined:
    Jun 19, 2015
    Posts:
    137
    Plugins:
    2
    Minecraft User:
    XFuriousMC
    I will try this, thanks for the effort xD :)
    applqpak likes this.

Share This Page

Advertisement