SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot Pie's Avatar
    Join Date
    Aug 2003
    Location
    UK
    Posts
    198
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [php] multi option list box

    $cat[] = $_POST['cat'];
    $cs = implode(",", $cat);
    echo "1: " . $cs[0] . "<br>2: " . $cs[1];


    Its splitting it by character, not by each answer

  2. #2
    Free your mind Toly's Avatar
    Join Date
    Sep 2001
    Location
    Panama
    Posts
    2,182
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try...

    PHP Code:
    $cs implode(","$_POST['cat']);
    echo 
    "1: " $cs[0] . "<br>2: " $cs[1]; 
    Community Guidelines | Community FAQ

    "He that is kind is free, though he is a slave;
    he that is evil is a slave, though he be a king." - St. Augustine

  3. #3
    SitePoint Zealot Pie's Avatar
    Join Date
    Aug 2003
    Location
    UK
    Posts
    198
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nope

  4. #4
    Free your mind Toly's Avatar
    Join Date
    Sep 2001
    Location
    Panama
    Posts
    2,182
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Shouldn't you use explode, anyways? You mention that you want to split, and implode is for joining.
    Community Guidelines | Community FAQ

    "He that is kind is free, though he is a slave;
    he that is evil is a slave, though he be a king." - St. Augustine

  5. #5
    SitePoint Enthusiast
    Join Date
    Dec 2003
    Location
    va
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Toly is right. Implode is for joining. So in this, cs is now a string instead of the array you want.
    Why don't you just output $cat[0] and $cat[1] and delete that line where $cs = implode(",",$cat)?
    That should do the trick.

  6. #6
    SitePoint Zealot Pie's Avatar
    Join Date
    Aug 2003
    Location
    UK
    Posts
    198
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I managed it once and cannot remember how now.

    $cs[0] brings out the first letter of the string. Not the first string in the array.


Bookmarks

Posting Permissions

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