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, 1466🔥, 0💬
Popular Posts:
What is Azure API Management Publisher Dashboard? Azure API Management Publisher Dashboard is an Azu...
Can You Specify the "new line" Character in Single-Quoted Strings? You can not specify the "new line...
Where to find tutorials on Visual Studio? I want to know How to learn Visual Studio. Here is a large...
How to convert JSON Objects to PHP Associative Arrays using the json_decode() function? Actually, JS...
How To Remove Slashes on Submitted Input Values in PHP? By default, when input values are submitted ...