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, ∼3808🔥, 0💬
Popular Posts:
How to use the "find-and-replace" Policy Statement for an Azure API service operation? The "find-and...
How to use the "set-backend-service" Policy Statement for an Azure API service operation? The "set-b...
Where to get the detailed description of the JSON.stringify() Function in JavaScript? Here is the de...
How to reinstall npm with a node version manager? I am getting permission errors with the current ve...
How to install "The Windows SDK version 8.1"? I need to build my Visual Studio C++ applications. If ...