note 97807 deleted from language.types.type-juggling by danbrown
| From: | danbrown@php.net | Date: | Mon, 10 May 2010 00:07:38 +0000 |
| Subject: | note 97807 deleted from language.types.type-juggling by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-169099@lists.php.net to get a copy of this message | ||
Note Submitter: leo at indeedle dot com
----
Just fixing up bhsmither at gmail.com's example.
If you want to refer to an array with a named key inside a string, use the {} brackets.
<?php
$foo['ten'] = 10; // $foo['ten'] is an array holding an integer at
key "ten"
$str = "{$foo['ten']}"; // Now works fine, $str now holds a string with
the value of 10
?>
This is useful when you want to include a array value inside a string without joining multiple
timesg.
Eg:
<?php
echo "There once was a man who had {$foo['ten']} geese.";
?>