Working with arrays

Example #3 1-based index with array()

= array(1 => 'January', 'February', 'March');

The above example will output:



[1] => January

[2] => February

[3] => March


As in Perl, you can access a value from the array inside double quotes.

However, with PHP you’ll need to enclose your array between curly braces.

Example #4 Accessing an array inside double quotes

<?php$foo = array('bar' => 'baz');

echo "Hello {$foo['bar']}!"; // Hello baz!


I got this info at

Leave a Reply