How do I get PHP to read and create multiple cells in one cell

Discussion in 'PHP' started by wwwbryan, Apr 2, 2009.

  1. #1
    Like how do I make it read information like this:

    where there's one cell and in that cell would be like:

    1,2 52,1 23,2

    Where a space means another cell. So this way I don't need to waste a bunch of cells and just use one cell in place of many.

    I've seen it done before except I am not sure how to do it myself.
     
    wwwbryan, Apr 2, 2009 IP
  2. rosseric

    rosseric Peon

    Messages:
    24
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    the question isn't quite clear. can you try to explain? how do you store that information?
     
    rosseric, Apr 2, 2009 IP
  3. wwwbryan

    wwwbryan Well-Known Member

    Messages:
    181
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    103
    #3
    Erm make one cell of the table sort of act like multiple cells by having multiple information in it.

    Instead of having one cell for each thing like

    Cell 1: 32,1
    Cell 2: 33,2

    And have it like

    Cell 1: 32,1 33,2

    And have a space indicate a new cell.
     
    wwwbryan, Apr 2, 2009 IP
  4. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #4
    You can explode() them into array using a space as delimiter.

    $cell = explode(" ",$yourstring);
    PHP:
    - ads2help
     
    ads2help, Apr 2, 2009 IP
  5. wwwbryan

    wwwbryan Well-Known Member

    Messages:
    181
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    103
    #5
    OK thanks a lot!, I will look into it when I get time tomorrow!
     
    wwwbryan, Apr 2, 2009 IP
  6. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #6
    If you need to search the database based on this information, then normalise it.

    Otherwise you can use serialize() and unserialize() to pack and unpack your arrays for storage.
     
    SmallPotatoes, Apr 3, 2009 IP