[SOLVED]var from var

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pppswing
Forum Commoner
Posts: 33
Joined: Thu Jun 10, 2004 2:04 am
Location: Tallinn, Estonia

[SOLVED]var from var

Post by pppswing »

Hello,
I've got a variable, let's say

Code: Select all

$a = 'bof';
and I got

Code: Select all

$bof = 'mytext';

and I want to get $bof through $a. How can I do that ?

Code: Select all

$$a
A this time I dont know if $a is 'bof' or 'super', because in fact I got

Code: Select all

$b = array('bof', 'super',...);
what I want is $$b[$i] but I dont know if it works puting $$ ?

Thanks
jslick
Forum Commoner
Posts: 35
Joined: Wed Jul 21, 2004 11:18 am

Post by jslick »

I don't think I understand. If you want $a to equal $bof ($a to equal 'mytext') then you say $a=$bof;
I don't believe I helped because I don't fully understand your question.
pppswing
Forum Commoner
Posts: 33
Joined: Thu Jun 10, 2004 2:04 am
Location: Tallinn, Estonia

Post by pppswing »

I want $$a i've never said that I want $a = $bof;

I got :

Code: Select all

$a ='bof';
$bof = 'my text';
$c = $$a; /* I want it to be 'mytext' */
jtc970
Forum Commoner
Posts: 38
Joined: Sun Jan 18, 2004 11:49 pm

Post by jtc970 »

that works when I test it
Post Reply