Re: Hashes in strings
| From: | Dan Hardiker | Date: | Thu, 01 Jan 1970 00:00:00 +0000 |
| Subject: | Re: Hashes in strings | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-95654@lists.php.net to get a copy of this message | ||
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