| 
 Posted by Andy Hassall on 10/04/06 00:41 
On Wed, 4 Oct 2006 00:33:26 +0200, "Garry Jones" <garry.jones@morack.se> wrote: 
 
>I need to nest a variable into a variable name. Having problem with syntax 
>Simply put 
> 
>$dtet is "col" 
>and $dn can be "blue" or "red" 
> 
>How do I get the following to work? 
> 
>$dtet+$dn = $_POST["dtet$dn"]; 
> 
>So that the result is either a variable called '$colblue' with a value of  
>'colblue' or a variable called '$colred' with a value of 'colred' 
 
 Variable variables: 
http://uk.php.net/manual/en/language.variables.variable.php 
 
 ${$dtet . $dn} = "whatever"; 
 
 But you may want to consider using associative arrays instead, unless you're 
forced to write it like this to interface with existing code. 
 
--  
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk 
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
 
  
Navigation:
[Reply to this message] 
 |