Serenitee Posted March 8, 2009 Share Posted March 8, 2009 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. Quote Link to comment Share on other sites More sharing options...
Serenitee Posted March 8, 2009 Author Share Posted March 8, 2009 Or perhaps create a 3rd array using the Value of both once the keys match. Either would work just fine (as the end result is what is needed). I swear manipulating array's will make my brain melt.. Quote Link to comment Share on other sites More sharing options...
Serenitee Posted March 8, 2009 Author Share Posted March 8, 2009 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. Quote Link to comment Share on other sites More sharing options...
WolfRage Posted March 8, 2009 Share Posted March 8, 2009 Can you post the rest of your code that is handling the array and the transfer of data between the two arrays. Quote Link to comment Share on other sites More sharing options...
Serenitee Posted March 8, 2009 Author Share Posted March 8, 2009 I "think" I got it, it does work with the above arrays as it should - any see any problems with it? foreach($chosenItems3 as $k => $v) if(array_key_exists($k, $finCountArr3)) {$testing[$v] = $finCountArr3[$k]; tia! Quote Link to comment Share on other sites More sharing options...
Serenitee Posted March 8, 2009 Author Share Posted March 8, 2009 Well, each test of it I do - it seems to be solid. Thanks to all that took a looksee Quote Link to comment 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.