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, ∼3901🔥, 0💬
Popular Posts:
How to how to use matched string and groups in replacements with re.sub()? When calling the re.sub()...
How to use "xml-to-json" Azure API Policy Statement? The "xml-to-json" Policy Statement allows you t...
How to use the built-in "context" object in Policy expressions? The built-in "context" object can be...
How To Set session.gc_divisor Properly in PHP? As you know that session.gc_divisor is the frequency ...
What is the "__init__()" class method? The "__init__()" class method is a special method that will b...