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.
⇒ Accessing a Specific Character in String in PHP
⇐ Ways to Include Variables in Double-Quoted Strings in PHP
2016-10-13, 1472🔥, 0💬
Popular Posts:
How to use the JSON to XML Conversion Tool at utilities-online.info? If you want to try the JSON to ...
How to run CMD Commands in Dockerfile to change Windows Docker images? When building a new Windows i...
How to add request URL Template Parameters to my Azure API operation to make it more user friendly? ...
How to run PowerShell Commands in Dockerfile to change Windows Docker images? When building a new Wi...
dev.FYIcenter.com is a Website for software developer looking for software development technologies,...