Reply to Re: Varaible Syntax

Your name:

Reply:


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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация