delayedinsanity Posted May 7, 2011 Share Posted May 7, 2011 "Cannot find search daemon". I tried. I've been wracking my brain for the last two hours trying to simplify this. It seems like I'm running over the two arrays far too many times, and that I should be able to do it in one pass somehow. I have two associative arrays, the first contains a set of older options (previous version), the second is a default set of new options. I want to compare the two arrays, and strip out any old options that aren't in the new set. I want to add options from the new set that aren't already in the old, and I don't want to overwrite and of the old options that already have values. Here's a copy of the sandbox I've been working it out in; it works, but it does four separate operations on the arrays to achieve the result: http://pastebin.com/erbFujkG Link to comment https://forums.phpfreaks.com/topic/235785-comparing-nested-associative-arrays/ Share on other sites More sharing options...
delayedinsanity Posted May 9, 2011 Author Share Posted May 9, 2011 Bump from page 3... I fixed the formatting (tabs vs spaces, oops) and repasted: http://pastebin.com/yD7u8bZ4 I know it's something simple I'm missing. A change in the function itself, somewhere, is going to reduce the number of times I have to run it from 3 to 1. Link to comment https://forums.phpfreaks.com/topic/235785-comparing-nested-associative-arrays/#findComment-1212611 Share on other sites More sharing options...
fugix Posted May 9, 2011 Share Posted May 9, 2011 what is your actual question? Link to comment https://forums.phpfreaks.com/topic/235785-comparing-nested-associative-arrays/#findComment-1212613 Share on other sites More sharing options...
delayedinsanity Posted May 9, 2011 Author Share Posted May 9, 2011 "It seems like I'm running over the two arrays far too many times, and that I should be able to do it in one pass somehow." It works; There are no errors that I'm trying to work out. I just thought I would pick everybody's brain to see if it was possible to do it more efficiently. Link to comment https://forums.phpfreaks.com/topic/235785-comparing-nested-associative-arrays/#findComment-1212632 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.