Need help in this work

Discussion in 'PHP' started by balasun, Jan 31, 2008.

  1. #1
    Hello!

    i have an variable like

    $serial = "newname=details"

    Now i want to split the above variable in to two parts like before 'name=' that is 'new' and after 'name=' that is 'details'.

    and store it in to two variables like below:
    $test = new
    $test1 = details.

    In variable $serial The value before 'name=' and after 'name=' is change dynamically.

    So i want to find where the string like 'name=' in $serial and want to fetch before and after value of 'name= 'n and store that values in separate two variables.

    Help me if you know the answer.Pls!
     
    balasun, Jan 31, 2008 IP
  2. thedark

    thedark Well-Known Member

    Messages:
    1,346
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    168
    Digital Goods:
    1
    #2
    try explode function: php.net/explode
     
    thedark, Jan 31, 2008 IP
  3. ltdraper

    ltdraper Peon

    Messages:
    30
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    $serial = "newname=details";
    list($test, $test1) = explode("=", $serial);
    echo $test." - ".$test1."\n";

    Or are you trying to do something different?
     
    ltdraper, Jan 31, 2008 IP
  4. balasun

    balasun Peon

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks For your reply. Now it works well.
     
    balasun, Jan 31, 2008 IP