Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Oct 2009
    Location
    United States
    Posts
    157
    Thanks
    8
    Thanked 4 Times in 4 Posts

    php variable combining

    Hello everybody.

    I'm trying to just get something to work that seems so simple, but for some reason I can't seem to figure it out.

    I'm just trying to have a variable like $test1 = 5; Then I have another variable that would be like $t = 1;

    Is it possible so that you could do something like: $test.$i to get the $test1 result?

    Thanks again for your time.

  • #2
    met
    met is offline
    Regular Coder
    Join Date
    Oct 2009
    Location
    United Kingdom
    Posts
    728
    Thanks
    4
    Thanked 119 Times in 119 Posts
    if you want to concat, yes:

    PHP Code:
    $a=1;
    $b=2;
    $c=$a.$b//$c=12;

    $c=$a+$b// $c=3 
    unless i misunderstand you

  • #3
    Regular Coder
    Join Date
    Oct 2009
    Location
    United States
    Posts
    157
    Thanks
    8
    Thanked 4 Times in 4 Posts
    Yeah, I'll try to explain it better.

    I'm trying to do something like this:
    PHP Code:
    $test1 5;
    $a 1;

    echo 
    $test.$a
    And then the $test.$a when echoed should be echoing 5. I just wasn't sure if this was possible, even though it seems simple. lol

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Maybe ${'test'.$t} would work? I dont see why you don't just use an array so $test[$t] would acess your particular value.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #5
    Regular Coder
    Join Date
    Oct 2009
    Location
    United States
    Posts
    157
    Thanks
    8
    Thanked 4 Times in 4 Posts
    That worked, thanks. . Not sure why I couldn't get it earlier. lol.

    And yeah, I was just seeing if I could get this way to work.

    Thanks again.


  •  

    Posting Permissions

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