faqts : Computers : Programming : Languages : PHP : Common Problems : Variables

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

9 of 12 people (75%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

How can I transform a string into the variable that has the name that string?For ex:the string results by concatenating other strings.String="name_2".

May 18th, 2001 01:24
Ovidiu Oprescu,


Sorry,It's me the one who wrote the question,I figured out myself,in 
the end, but because I think this is helpfull for others, I decided to 
answer to my own question:
For this kind of situations exists what is called in PHP variable 
variables:
for ex:
<?php
$a="nume";
$$a="John Smith";
echo "$a ${$a}";
?>
That's it!