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, 1500🔥, 0💬
Popular Posts:
How to Install Docker Desktop on Windows 10? You can follow this tutorial to Install Docker Desktop ...
Why I am getting "The Windows SDK version 8.1 was not found" error, when building my C++ application...
How to register and get an application ID from Azure AD? The first step to use Azure AD is to regist...
How to send an FTP request with the urllib.request.urlopen() function? If an FTP server supports ano...
What is EPUB 3.0 Metadata "dc:publisher" and "dc:rights" elements? EPUB 3.0 Metadata "dc:publisher" ...