Re: Hashes in strings

From: Date: Thu, 02 May 2002 15:15:17 +0000
Subject: Re: Hashes in strings
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-95701@lists.php.net to get a copy of this message
Hi, I would suggest not to use $hash[var1][var2] instead of $hash['var1']['var2'] because afaik php will think u mean two constants ( var1 and var2 ). Just if it doesnt find these constants it will use them as $hash['var1']['var2']. Markus Mirsberger "Dan Hardiker" <dhardiker@staff.firstcreative.net> schrieb im Newsbeitrag news:63606.194.222.31.228.1020329607.squirrel@adam.firstcreative.net... > Hi, > > I think this will accomplish what your trying to achieve. > > $str = "I can use $hash[vars] in strings"; > > However, this will not work for multi dimensional arrays... eg: > > $hash['var']['var2'] = "Elephant"; > $str = "I can NOT use $hash[var][var2] in strings"; > > will output "I can NOT use Array[var2] in strings". For this you have to > jump out of the string and use contcatination... eg: > > $str = "I can use ".$hash[var][var2]." in strings"; > > will output "I can use Elephant in strings". > > Hope that helps :) > > -- > Dan Hardiker [dhardiker@staff.firstcreative.net] > ADAM Software & Systems Engineer > First Creative Ltd > > > Hey there, > > > > why do these work: > > $vars = "vars"; > > $ar[0] = "arrays"; > > $hash['vars'] = "hashes"; > > str = "I can use $vars in strings"; > > str = "I can use $ar[0] in string"; > > > > while this one doesn't: > > str = "I can NOT use $hash['vars'] in strings"; > > > > Kind regards > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#95701) next »