By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,747 Members | 1,671 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,747 IT Pros & Developers. It's quick & easy.

Is there a way to do this with variables?

P: n/a
ok so I have for example $f1, $f2, $f3, $f4... $f22.

i want a

for ($i = 1; $i <= 22; $i++)
{
if ($f$i == 1) { } // The variable should turn into $f1, $f2, etc
}
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
In article <10*************@corp.supernews.com>, Brandon Lamb wrote:
ok so I have for example $f1, $f2, $f3, $f4... $f22.

i want a

for ($i = 1; $i <= 22; $i++)
{
if ($f$i == 1) { } // The variable should turn into $f1, $f2, etc
}


eval?

--
http://home.mysth.be/~timvw
Jul 17 '05 #2

P: n/a
Regarding this well-known quote, often attributed to Brandon Lamb's famous
"Fri, 16 Apr 2004 12:36:43 -0700" speech:
ok so I have for example $f1, $f2, $f3, $f4... $f22.

i want a

for ($i = 1; $i <= 22; $i++)
{
if ($f$i == 1) { } // The variable should turn into $f1, $f2, etc
}


Curly braces:
${"f$i"} == $f1
(assuming $i == 1)

--
-- Rudy Fleminger
-- sp@mmers.and.evil.ones.will.bow-down-to.us
(put "Hey!" in the Subject line for priority processing!)
-- http://www.pixelsaredead.com
Jul 17 '05 #3

P: n/a
On Fri, 16 Apr 2004 12:36:43 -0700, "Brandon Lamb" <br*****@olypen.com> wrote:
ok so I have for example $f1, $f2, $f3, $f4... $f22.

i want a

for ($i = 1; $i <= 22; $i++)
{
if ($f$i == 1) { } // The variable should turn into $f1, $f2, etc
}


Variable variables. But you'd be better off with an array.

--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.