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
https://forums.phpfreaks.com/topic/148415-solved-arrays-are-making-me-cry-again/
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.

 

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.