[thelist] building a dynamic variable in php

Tom Dell'Aringa thelist at lists.evolt.org
Mon Jan 13 11:59:01 2003


--- Carl J Meyer <cjmeyer at npcc.netrote:
> Hi Tom,  here's the code you need,
>
> -------------
> for($i = 1; $i < 10; $i++) {
>   $var = 'mail' . $i;
>   ${$var} = $_POST[$i];
> }
> -------------
>
> This will set the variables $mail1 through $mail10.  'Course I
> rarely
> see any reason to do this sort of thing when you could just use an
> array
> ( $mail[1] through $mail[10] )...

Would an array be better? How would I do it with an array?

Tom

=====
var me = tom.pixelmech.webDeveloper();

http://www.pixelmech.com/
http://www.maccaws.com/
[Making A Commercial Case for Adopting Web Standards]

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com