Jump to content

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;

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.