Jump to content

[SOLVED] Arrays are making me cry again :(


Serenitee

Recommended Posts

I currently have 2 arrays:

 

$finCountArr3 = Array('Blazed Cailiocht Sleeves' => 3, 'Blazed Cailiocht Wreath' => 9, 'Blazed Cailiocht Leggings' => 1, 'Dragonsworn Blazed Cailiocht Gloves' => 8, 'Blazed Cailiocht Boots' => ;

$chosenItems3 = Array('Blazed Cailiocht Sleeves' => 'crystalized Blazed Cailiocht Sleeves', 'Blazed Cailiocht Wreath' => 'crystalized Blazed Cailiocht Wreath',
'Blazed Cailiocht Leggings' => 'crystalized Blazed Cailiocht Leggings', 'Dragonsworn Blazed Cailiocht Gloves' => 'crystalized Dragonsworn Blazed Cailiocht Gloves', 'Blazed Cailiocht Boots' => 'crystalized Blazed Cailiocht Boots');

 

I need to check the keys of both, and when there is a match, update the "$finCountArr3" key to the $chosenItems3 value so the end result would be:

 

crystalized Blazed Cailiocht Sleeves => 3

crystalized Blazed Cailiocht Wreath => 9

crystalized Blazed Cailiocht Leggings => 1

crystalized Dragonsworn Blazed Cailiocht Gloves => 8

crystalized Blazed Cailiocht Boots => 8

 

I've tried many searches (and test codes) including an "if (array_key_exists...."  but I seem to have made a mess of it, and it doesn't seem to like that they are both associative arrays.

 

Any pointers in the right direction would be much appreciated.

 

Link to comment
Share on other sites

This is the closest I've gotten thus far:

foreach($chosenItems3 as $key )
{$testing[$key] = $finCountArr3[$key];}

 

provides:

Array

(

    [crystalized Blazed Cailiocht Sleeves] =>

    [crystalized Blazed Cailiocht Wreath] =>

    [crystalized Blazed Cailiocht Leggings] =>

    [crystalized Dragonsworn Blazed Cailiocht Gloves] =>

    [crystalized Blazed Cailiocht Boots] =>

)

 

It doesn't seem to be matching from the 2nd (finCountArr3) array & providing the value from that array however.

 

Link to comment
Share on other sites

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.