MasterACE14 Posted August 15, 2009 Share Posted August 15, 2009 Hi, I have an array set up like so... $item[1]['weapon']['name'] = "Knife"; $item[1]['weapon']['damage'] = 5; $item[1]['weapon']['durability'] = -1; $item[1]['weapon']['reqlvl'] = 1; $item[1]['weapon']['level'] = 1; $item[2]['armour']['name'] = "Helmet"; $item[2]['armour']['damage'] = 5; $item[2]['armour']['durability'] = -1; $item[2]['armour']['reqlvl'] = 1; $item[2]['armour']['level'] = 1; if I do something like this... echo $item[35][$type]['name']; how would I work out what type it is? workout whether it is 'weapon' or 'armour' ? Thanks, Ace Quote Link to comment https://forums.phpfreaks.com/topic/170366-solved-which-key-is-it/ Share on other sites More sharing options...
Prismatic Posted August 15, 2009 Share Posted August 15, 2009 $type would tell you if it's a weapon or armour Quote Link to comment https://forums.phpfreaks.com/topic/170366-solved-which-key-is-it/#findComment-898703 Share on other sites More sharing options...
MasterACE14 Posted August 15, 2009 Author Share Posted August 15, 2009 lol, my question is how do I get to the point where I have $type in the first place? I'm trying to figure out how to check whether the second key in the array is armour or weapon, and then I would make $type = "weapon"; or $type = "armour"; Quote Link to comment https://forums.phpfreaks.com/topic/170366-solved-which-key-is-it/#findComment-898704 Share on other sites More sharing options...
Philip Posted August 15, 2009 Share Posted August 15, 2009 Why not just do: $item[1]['type'] = "weapon"; $item[1]['name'] = "Knife"; $item[1]['damage'] = 5; $item[1]['durability'] = -1; $item[1]['reqlvl'] = 1; $item[1]['level'] = 1; $item[2]['type'] = "armour"; $item[2]['damage'] = 5; $item[2]['durability'] = -1; $item[2]['reqlvl'] = 1; $item[2]['level'] = 1; Quote Link to comment https://forums.phpfreaks.com/topic/170366-solved-which-key-is-it/#findComment-898717 Share on other sites More sharing options...
MasterACE14 Posted August 15, 2009 Author Share Posted August 15, 2009 point taken, I shall do that. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/170366-solved-which-key-is-it/#findComment-898718 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.