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, ∼1992🔥, 0💬
Popular Posts:
How to install "C++/CLI Support" component in Visual Studio? I need to build my Visual Studio C++/CL...
How To Truncate an Array in PHP? If you want to remove a chunk of values from an array, you can use ...
How to use the XML to JSON Conversion Tool at freeformatter.com? If you want to try the XML to JSON ...
Where to find tutorials on RSS specifications? I want to learn it to describe my API services. Here ...
How To Create an Array with a Sequence of Integers or Characters in PHP? The quickest way to create ...