Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 9 of 9
  1. #1
    Join Date
    Sep 2006
    Location
    Hobart, Australia
    Posts
    593
    Tokens
    0

    Default explode() with new lines...

    Hey guys, hoping you can help me.

    I've got a textarea box, which i want to enter a bunch of things on a new line into. Once the form is submitted, the data gets sent to a MySQL database. I want to use PHP's explode function to break each new line into it's own entry in an array.

    This is where I hit a snag.

    No matter what I make the delimiter, it won't work. I've tried "\r\n", "\r", "\n" and all variations thereof. I can't get it to split in it's own array entries.

    What am I doing wrong?

    Thanks in advance

  2. #2
    Join Date
    Oct 2006
    Location
    Peterborough, UK
    Posts
    3,855
    Tokens
    216

    Latest Awards:

    Default

    Remember to put \\ not \


    visit my internet web site on the internet
    http://dong.engineer/
    it is just videos by bill wurtz videos you have been warned

  3. #3
    Join Date
    Dec 2006
    Posts
    3,970
    Tokens
    0

    Latest Awards:

    Default

    You could cheat and do

    explode("
    ", $textarea);
    Lets set the stage on fire, and hollywood will be jealous.

  4. #4
    Join Date
    Nov 2008
    Posts
    248
    Tokens
    0

    Default

    you need to put // =] dont realy no much about php tho so i carnt realy help.

  5. #5
    Join Date
    Sep 2005
    Location
    East London
    Posts
    3,028
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Jebbo. View Post
    you need to put // =] dont realy no much about php tho so i carnt realy help.
    All you did is read Jewish Bear's post, and because you know he's ought to be right because hes amazing at PHP, you just repeated his response.

    -rep if i can

  6. #6
    Join Date
    Jul 2008
    Location
    Hastings, UK.
    Posts
    2,050
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Jackboy View Post
    All you did is read Jewish Bear's post, and because you know he's ought to be right because hes amazing at PHP, you just repeated his response.

    -rep if i can
    I was just about to post the same.

    Don't bother posting if you're not offering help, you're just repeating it..

    Fail.

  7. #7
    Join Date
    Feb 2007
    Location
    Essex, England
    Posts
    1,392
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Jebbo. View Post
    you need to put // =] dont realy no much about php tho so i carnt realy help.
    Not only did you copy, you failed to notice that it's \\, not //.


  8. #8
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    You could just easily do this..

    PHP Code:
        $text nl2br$text );
        
    $text explode'<br />'$text ); 
    Puts them into an array...

    print_r() if you want to see the values.. then just throw them into a foreach and you can do what you want with them..

    PHP Code:
        foreach( $text as $line ) {
            
    // your variable here is going to be $line, do what you want with it.
            
    echo $line;
        } 

  9. #9
    Join Date
    May 2008
    Posts
    1,160
    Tokens
    11

    Latest Awards:

    Default

    Quote Originally Posted by Calon View Post
    I was just about to post the same.

    Don't bother posting if you're not offering help, you're just repeating it..

    Fail.

    Lol. Thinking the same think -REP for Jebbo if I can also. .
    EDIT: Ah shiz lol wasn't paying attention and +REP'd him LOOOOl Dumb me
    Last edited by Cushioned; 08-11-2008 at 07:59 PM.
    Previously a Habbo fanatic, web designer/developer, fansite owner, & trusted member of the community.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •