This maybe duplicate, but I couldn't find the anwser looking aroud topics.
I have an array, witch looks like this:
$itemx=
[
'Weapons'=>[
'Sword'=> [
'Name' => 'Lurker',
'Value' => '12',
'Made' => 'Acient'
],
'Shield'=> [
'Name' => 'Obi',
'Value' => '22',
'Made' => 'Acient'
],
'Warhammer'=> [
'Name' => 'Clotch',
'Value' => '124',
'Made' => 'Acient'
]
],
'Drinks'=>[
'Water'=> [
'Name' => 'Clean-water',
'Value' => '1',
'Made' => 'Acient'
],
'Wine'=> [
'Name' => 'Soff',
'Value' => '5',
'Made' => 'Acient'
],
'Vodka'=> [
'Name' => 'Laudur',
'Value' => '7',
'Made' => 'Acient'
]
]
];
I want to echo out the item Categories(Weapons,Drinks),Types(Sword,Water,etc) what they hold.
I tried just an regular foreach and so they echo arrays.
function getAllCategories()
{
foreach ($this->_prop as $cate)
{
echo $cate;
foreach ($cate as $type)
{
echo $type;
}
}
}
So i thought I can select from the arrays.
function getAllCategories()
{
foreach ($this->_prop as $cate)
{
echo $cate[0];
foreach ($cate as $type)
{
echo $type[0];
}
}
}
But they echo'd nothing and I dont understand how could I print those values out that I want.