Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-15-2010, 07:10 PM   PM User | #1
votter
Regular Coder

 
Join Date: Oct 2009
Location: United States
Posts: 149
Thanks: 7
Thanked 4 Times in 4 Posts
votter is on a distinguished road
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.
votter is offline   Reply With Quote
Old 05-15-2010, 07:11 PM   PM User | #2
met
Regular Coder

 
Join Date: Oct 2009
Location: United Kingdom
Posts: 728
Thanks: 4
Thanked 119 Times in 119 Posts
met has a little shameless behaviour in the past
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
met is offline   Reply With Quote
Old 05-15-2010, 07:14 PM   PM User | #3
votter
Regular Coder

 
Join Date: Oct 2009
Location: United States
Posts: 149
Thanks: 7
Thanked 4 Times in 4 Posts
votter is on a distinguished road
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
votter is offline   Reply With Quote
Old 05-15-2010, 07:28 PM   PM User | #4
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Maybe ${'test'.$t} would work? I dont see why you don't just use an array so $test[$t] would acess your particular value.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Old 05-15-2010, 07:33 PM   PM User | #5
votter
Regular Coder

 
Join Date: Oct 2009
Location: United States
Posts: 149
Thanks: 7
Thanked 4 Times in 4 Posts
votter is on a distinguished road
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.
votter is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:44 AM.


Advertisement
Log in to turn off these ads.