I don't know the answer to why, but you can do this:
$str = I can use .$hash['vars']. in strings;
:)
Justin French
Creative Director
http://Indent.com.au
on 02/05/02 6:42 PM, Ferry van Steen ([EMAIL PROTECTED]) wrote:
Hey there,
why do these
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]
Ferry van Steen wrote:
while this one doesn't:
str = I can NOT use $hash['vars'] in strings;
Try this one:
str = I can NOT use .$hash['vars']. in strings;
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
-Original Message-
From: Ferry van Steen [mailto:[EMAIL PROTECTED]]
Sent: 02 May 2002 09:42
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
Thanks for the replies peoples :-)
-Original Message-
From: Ford, Mike [LSS] [mailto:[EMAIL PROTECTED]]
Sent: donderdag 2 mei 2002 11:13
To: 'Ferry van Steen'; [EMAIL PROTECTED]
Subject: RE: [PHP] Hashes in strings
-Original Message-
From: Ferry van Steen [mailto:[EMAIL
Not really sure but str has to be $str, and I usually do print lines like
this
$str = I can NOT use .$hash['vars']. in strings;
the . will concat the strings together.
Hope this helps,
-Steve
-Original Message-
From: Ferry van Steen [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 02,
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 [EMAIL PROTECTED] schrieb im
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'].
Thats correct, php will think they are constants and upon
One thing to note is that constants are not looked for
within strings. So:
// This is okay but can cause confusion. No errors
// are created but many prefer not to do this.
$str = Hello $there[friend], how are you?;
Outside of a string, $there[friend] will indeed seek
a constant
9 matches
Mail list logo