I have two arrays with around 50 fields each, one is an array of users, which was obtained from db and looks like this (shortened to only 3 fields)
Array( [0] => Array([id] => 1 [email] => email1@hotmail.com [last_name] => Lastname)
[1] => Array([id] => 2 [email] => email2@hotmail.com [last_name] => Lastname2)
);
My other array, is an array of fields, where key is the name of the field, and value is the field in the users table (shortened as well):
Array([User ID] => id [Last Name] => last_name [Email] => email);
Now, I want to produce an array to compare two users, and after a couple of foreach I got this array:
Array([id] => Array([0] => 1 [1] => 2)
[email] => Array([0] => email1@hotmail.com [1] => email2@hotmail.com)
[last_name] => Array([0] => Lastname [1] => Lastname2)
This last array, as you can see, contains the id for the two users, email for both, etc. which is used to make comparisons. This works, however, you can see that the order does not correspond to the names of the fields array. I would like the third array to be created according to the order of the second array (that is, 1) id, 2) last name, 3) email)
How can that be achieved?