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 nam
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
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
ROTECTED]]
Sent: Thursday, May 02, 2002 4:42 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Hashes in strings
Hey there,
why do these work:
$vars = "vars";
$ar[0] = "arrays";
$hash['vars'] = "hashes";
str = "I can use $vars in strings";
str = "I
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 Stee
> -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
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
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[v
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 th
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.
10 matches
Mail list logo