how arrays embedded in strings will be converted. : echo « Utility Function « PHP






how arrays embedded in strings will be converted.

 
<?php

$arr = array(
  1 => "abc",
  "abc" => 123.5,
  array(1,2,3)
);
$key = "abc";

echo "First value = $arr[1]\n";
echo "Second value = $arr[abc]\n";
echo "Third value = $arr[2]\n";
echo "Third value = $arr[2][2]\n";

echo "Second value = ${arr['abc']}\n";
echo "Second value = ${arr["abc"]}\n";
echo "Second value = ${arr[$key]}\n";
?>
  
  








Related examples in the same category

1.A Simple "Hello World" Script
2.Add lines and spaces to textarea
3.Correct escaping of special characters
4.Formatting of Numeric Data
5.Key-value array elements
6.Echo out html tags
7.Enclosure html into a string and echo out
8.echo versus print
9.echo is more useful because you can pass it several parameters
10.embedded variables are handled when the string is created with single or double quotes.