dynamically creating variables

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
dsdsdsdsd
Forum Commoner
Posts: 60
Joined: Fri Dec 05, 2003 3:10 pm

dynamically creating variables

Post by dsdsdsdsd »

hello;

I have:

Code: Select all

$array = ("aaa","bbb","ccc");
I want to create variables:

Code: Select all

$aaa_string = "";
$bbb_string = "";
$ccc_string = "";
this loop will not do it though:

Code: Select all

for ($i=0 ; $i<count($array) ; $i++)
  &#123; $array&#1111;$i] . "_string" = "";
  &#125;
any thoughts?

thanks
Shannon Burnett
Asheville NC USa
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

try something like:

Code: Select all

$&#123;$array&#1111;0].'_string'&#125; = '';
dsdsdsdsd
Forum Commoner
Posts: 60
Joined: Fri Dec 05, 2003 3:10 pm

Post by dsdsdsdsd »

thanks hawleyjr
Post Reply