Jump to content

[SOLVED] which key is it?


MasterACE14

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/170366-solved-which-key-is-it/
Share on other sites

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";

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;

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.