Spliting a Variable?

Discussion in 'PHP' started by Zipp425, Sep 26, 2006.

  1. #1
    I was wondering if there was a way to split a variable into a set amount of peices?
     
    Zipp425, Sep 26, 2006 IP
  2. DrMalloc

    DrMalloc Peon

    Messages:
    130
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #2
    there area few, depending on what you want to split the variable up by (e.g a delimeter, a number of characters)
     
    DrMalloc, Sep 26, 2006 IP
  3. wmtips

    wmtips Well-Known Member

    Messages:
    601
    Likes Received:
    70
    Best Answers:
    1
    Trophy Points:
    150
    #3
    Yes, but implementation really depends on variable type. Supply more details if you want to get an answer.
     
    wmtips, Sep 26, 2006 IP
  4. codeber

    codeber Peon

    Messages:
    578
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #4
    you can split in various ways

    i personally like explode (which separates by delimiter [in my example below : a space] into an array)
    $newvar = explode(" ",$var);
    echo $newvar[0];
     
    codeber, Sep 26, 2006 IP
  5. Zipp425

    Zipp425 Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    more details...
    the variable to long and so when i request it via XMLHTTPREQUEST, it gets cut off by firefox. However, If I split the variable, and then request two to three separate variables, I dont run into the problem.

    Codeber's method should work just fine. Thanks Codeber
     
    Zipp425, Sep 26, 2006 IP
  6. cancer10

    cancer10 Guest

    Messages:
    364
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    codeber, thats not the way to split up a variable, thats the way to split up a string in the variable..

    Thanx
     
    cancer10, Sep 27, 2006 IP