Page 1 of 1

Creating a variable with a variable

Posted: Sun Jan 30, 2005 3:36 pm
by juan
I am trying to make a variable inside a loop from another variable. For example:

inside the loop I have variable $currentrow that tells me which row the loop is on

I want to make a variable named $news_[value of current row]

so when $currentrow is 5, it makes a variable $news_5.

How do I go about doing this?

Thanks,
Jon

Posted: Sun Jan 30, 2005 3:40 pm
by feyd
why not use arrays?

for "dynamic" variable create read the documentatio on variable variables: http://www.php.net/manual/en/language.v ... riable.php

Posted: Sun Jan 30, 2005 4:11 pm
by juan
Well actually I do plan on using an array, but I want

array_1
array_2
array_3

with the # according to the value of $currentrow

Posted: Sun Jan 30, 2005 4:12 pm
by juan
Nevermind,

I just realized it would probably be easier to do an array inside an array.

Thanks for help though.

Posted: Sun Jan 30, 2005 8:42 pm
by rehfeld