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

Array to string cOnversion error

Comments in 'Plugin Development' started by FlamingGenius, Sep 27, 2015.

  1. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    This code is causing me to have a array to strig conversion error and im not sure what im supposed to do to fix ito_O
    PHP:
    $msg implode(" " $args);

    If(
    strtolower($cmd) == "broadcast"){
     
    $this->getServer()->broadcastMessage("[Broadcast]" " " $msg);
  2. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    It should be implode(" ", $args) not implode(" " . $args). Please use an IDE(if you know what it means).
    abxyHD and Kvetinac97 like this.
  3. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    Integrated development envirmoment and i have one
  4. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Anyways the correction I gave you in my previous post should fix this problem. Anyways, for more information on how to use implode() and what it's parameters are, look here: http://php.net/manual/en/function.implode.php
  5. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    Its funny because before i changed my code for implode() i lookes at this exact page lol helped me understand that what every is betweEn the " " is what the words in the array are seperated by lol i just tottaly missed the fact that it was a comma I seriously dont know what i was thinking that was a common sense thing i should have known it was a comma
  6. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Learn the difference here: http://stackoverflow.com/questions/1466408/difference-between-and-in-php
  7. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
  8. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    And that's why you have to learn how to read through documentations and code and actually use your brain, not everything will be taught to you by a teacher in life, some things you have to learn on your own.
  9. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    Everyone has thier own way...on a side not do you think this would be accepted?
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Ignore @Gamecrafter. He is just here to bring up flame wars.
    `.` means to combine two strings together. $args is a string array. Please read the documentation of implode at https://php.net/implode - the first parameter is the glue, and the second parameter is an array of the pieces you want to glue.
    `,` is used to separate two arguments in the argument list while calling a function. If you don't understand what functions are, please learn PHP.
    iJoshuaHD and jojoe77777 like this.
  11. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    Yea i did some studying on implode i get it now adm what are flame wars? Is that like a joke abt my name?
  12. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    No. Flame wars mean to argue on something that isn't related to the topic and often results in a lot of spam posts, with two or more users criticizing each other.
    iJoshuaHD and jojoe77777 like this.

Share This Page

Advertisement