Re: Representing a variable

From: Date: Sun, 26 Apr 2015 12:40:06 +0000
Subject: Re: Representing a variable
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-324829@lists.php.net to get a copy of this message
Ron Piggott wrote: > I am wondering how to correctly represent the variable > $params['en-US_translation'] > > $value = 'en-US'; > > What I currently have is > > $params[{$value . '_translation'}] That is supposed to be a syntax error (see <http://3v4l.org/QQ2uI>). Either omit the curly braces: $params[$value . '_translation'] or use variable interpolation: $params["{$value}_translation"] You can't, however, use the following: $params["$value_translation"] That would look for a variable $value_translation. See also <http://php.net/manual/en/language.types.string.php#language.types.string.parsing>. -- Christoph M. Becker

« previous php.general (#324829) next »