Tools, FAQ, Tutorials:
Including Array Elements in Double-Quoted Strings in PHP
How Many Ways to Include Array Elements in Double-Quoted Strings?
✍: FYIcenter.com
There are 2 formats to include array elements in double-quoted strings:
Here is a PHP script example of different ways to include variables in double-quoted strings:
<?php $fruits = array('strawberry' => 'red', 'banana' => 'yellow'); echo "A banana is $fruits[banana].\n"; echo "A banana is {$fruits['banana']}.\n"; ?>
This script will print:
A banana is yellow. A banana is yellow.
"A banana is $fruits['banana'].\n" will give you a syntax error.
Â
⇒Understanding PHP String Literals and Operations
⇒⇒PHP Tutorials
2016-10-13, 1151👍, 0💬
Popular Posts:
What is test testing area for? The testing area is provided to allow visitors to post testing commen...
What is test testing area for? The testing area is provided to allow visitors to post testing commen...
FYIcenter.com Online Tools: FYIcenter JSON Validator and Formatter FYIcenter JSON to XML Converter F...
How to build a test service operation to dump everything from the "context.Request" object in the re...
How To Pad an Array with the Same Value Multiple Times in PHP? If you want to add the same value mul...