Array
(
[0] => My String
[1] => 42
[2] => Array
(
[0] => 42
[1] => 100
[2] => 24601
[3] => My Other String
)
[associative] => Array
(
[FirstName] => Shyam
[LastName=] => Singh
[Age] => 18
)
)
JSON: {"0":"My String","1":42,"2":[42,100,24601,"My Other String"],"associative":{"FirstName":"Shyam","LastName=":"Singh","Age":18}}
END OF OUTPUT
Source Code of crazyArrays.php
<?php
$arr = array();
//We can directly access indices in an array
$arr[0] = "My String";
$arr[1] = 42;
//Or even create arrays at points within an existing array
$arr[2] = array();
$arr[2][0] = 42;
$arr[2][1] = 100;
$arr[2][2] = 24601;
$arr[2][3] = "My Other String";
//NEW - we can make somethign called 'associative' arrays
// Here we aren't using index numbers at all, but words as our index
$arr["associative"] = array(
"FirstName" => "Shyam",
"LastName=" => "Singh",
"Age" => 18
);
//Time to print out our array and see what it looks like
//We use PRE tags just to preserve output formatting
echo "<pre>\n";
print_r($arr);
echo "\n\nJSON: ";
echo json_encode($arr);
echo "</pre>\n";
?>
<?php //WILL DISPLAY CODE OF THIS FILE ON THE WEBPAGE//
######################################################################
echo "<br/><br/><hr><hr>";
echo "<h2 style='text-align:center'>END OF OUTPUT</h2>\n";
echo "<hr><hr>";
echo "<h2><br>Source Code of ".basename((string)__FILE__) . "</h2><hr>";
show_source(__FILE__);
#######################################################################
?>