Re: dynamically named variables?

From: Date: Thu, 23 May 2002 17:18:20 +0000
Subject: Re: dynamically named variables?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-98949@lists.php.net to get a copy of this message
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 * and then Ford, Mike [LSS] declared.... > > Here's the coup: > > > > I have a bunch of post vars, lets say $red, $green and $blue > > I want to loop through the post vars and create a variable callled > > $file_red, $file_green and $file_blue > > Try this (untested!): > > foreach($_POST as $key=>$value): > ${"file_$key"} = $value; > endforeach; Worked a treat, cheers Mike! - -- Nick Wilson // www.explodingnet.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) iD8DBQE87SRcHpvrrTa6L5oRAuAEAKCYTILrONLQwz82LCQzeHoFAEbIrgCgrlE+ I1WGK+d9Fpu2nFOqOYxFnqk= =r91v -----END PGP SIGNATURE-----

« previous php.general (#98949) next »