1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

TypeError: "in_array() expects parameter 2 to be array, string given"

Discussion in 'Development' started by LousWiteMC, Jul 28, 2019.

  1. LousWiteMC

    LousWiteMC Spider

    Messages:
    6
    GitHub:
    LousWiteMC
    foreach(Lotto::getInstance()->getServer()->getOnlinePlayers() as $player){
    $item = Item::get(Lotto::getInstance()->getSetting("ID-Item-Ticket"),Lotto::getInstance()->getSetting(("ID-Meta-Ticket")));
    $nameitem = $item->getCustomName();
    $random = Lotto::getInstance()->getRandomNumber();
    $inv = $player->getInventory();
    if(!($inv->contains($item))){
    Lotto::getInstance()->getServer()->getOnlinePlayers()->sendMessage("§eLotto System\n§cNobody Had Won On This Lottery");
    }
    if(in_array($random, $nameitem)) {
     
  2. LousWiteMC

    LousWiteMC Spider

    Messages:
    6
    GitHub:
    LousWiteMC
    I don't know how to use in_array, have me to fix it!
     
  3. HeyDeniis_

    HeyDeniis_ Baby Zombie

    Messages:
    137
    PHP:
    if(in_array($value$array)){

    }

    or
    if(
    in_array($value, array($nameItem))){
    }
     
  4. LousWiteMC

    LousWiteMC Spider

    Messages:
    6
    GitHub:
    LousWiteMC
    thanks! it worked with if(in_array($value, array($nameItem))){
     
  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.