Posts: 2,536
Location: Western Maryland
|
A couple of things here. You are trying to declare your $shops array as associative given the index names "No such shop," "Weapons," etc. But then you make assignments using integer indices -- treating it as a sequential array. Try this code:
PHP Code:
<?php
$shops = array("No such shop" => array(), "Weapons" => array(), "Food" => array(), "Toys" => array());
$shops["No such shop"]["type"] = "none";
$shops["Weapons"]["type"] = "weapon";
$shops["Food"]["type"] = "food";
$shops["Toys"]["type"] = "toy";
$shops["No such shop"]["description"] = "Sorry this shop does not exist!";
$shops["Weapons"]["description"] = "Teach your pet(s) the art of self defence";
$shops["Food"]["description"] = "Yum!";
$shops["Toys"]["description"] = "Every pet loves a new toy";
?>
Now, you are not storing the term "Weapons" anywhere -- it is the string key to an associative array within $shops. To print it, you must assign it to a value of the array, not the key. For example, we are assigning "weapon" to $shops["Weapons"]["type"], so you could print it using that variable:
PHP Code:
print $shops["Weapons"]["type"];
__________________
—Kyrnt
|