Now i want to merge this arrays where ever the userid of user and usermeta are same, and i don’t want to use foreach loop in archiving it, am looking at array_walk or other inbuilt array functions.
Yes i wan to merge the two but won’t follow the arrays keys because they are not same keys with usersmeta keys, however I wan to find anywhere userid is 1 in users array and also userid is 1 in usermeta
if am to use foreach loop i would have sort the array keys and use them to merge the two affected arrays like this $data = array_merge($a[$keya], $b[$keyb]);
He’s not trying to ‘merge’ in the sense of appending, he’s trying to ‘merge’ in the sense of zipping. But his arrays dont have the same indexes.
(in SQL terms: He wants to OUTER JOIN the users array and the usersmeta array ON users.userid = usersmeta.userid)
I don’t even care about the indexes, all I want is to have the exact user id from users array to be merged below the usersmeta array and be as one single array.
So i am expected to have two arrays with full datas properly merged.
but when you look carefully you will notice that the correct value of city of the userid 2 is Sharidan and during our merging it properly came under the userid of 2
By default [userid] is overwritten with new values i am aware of it and we can’t have same key in a single array
Wow this is perfect, thanks alot but i need to know how the array_map() worked, it gave me the results I needed but I need to know how it did it, what and what was mapped?
Really? So in real sense it was not actually looking for values of userid in both arrays then merge them using their keys regardless of which position the value was found?