inserting string in to variable and echoing it

Discussion in 'PHP' started by ignas2526, Nov 16, 2008.

  1. #1
    The thing i trying to do is to insert string in to variable and then echo it.
    Lets say i want to echo $string123, but i only know what its starts from $string, and then user specifies how its ends. So i need somehow add after $string what user specified. Any ideas how to do what?
    And if not, is there any other ways to do same thing?
    Thanks.
     
    ignas2526, Nov 16, 2008 IP
  2. xenous

    xenous Peon

    Messages:
    102
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    use an array it is the easiest way $stirng[user_name]=value;
     
    xenous, Nov 16, 2008 IP
  3. garrettheel

    garrettheel Peon

    Messages:
    341
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #3
    do you mean like this?
    
    $my_code = 'test';
    $user_code = '123';
    
    $string = $my_code . $user_code;
    
    echo $string;
    
    Code (markup):
    or..

    
    
    $user_code = '123';
    
    $string = 'test';
    $string .= $user_code;
    
    echo $string;
    
    
    Code (markup):
     
    garrettheel, Nov 16, 2008 IP