I've managed to extract data from a database and assigned them into array called $NameandAge
(Peter:12, Kim:32, Paul:23)
On the other hand, I have also extracted another set of data from a different set of database and assigned them into array $StateandName
(New York:Peter, Washington:Kim, Tennessee:Paul)
What I what to achieve is to join these two sets of array into one using the Name as the key to create a table like this:
New York Peter 12,
Washington Kim 32,
Tennessee Paul 23,
I have something like below, however this takes a very long time for execution, giving me a timeout. I am looking for a better way to achieve this.
for(){ ///////////////loop array $StateandName
for(){ ////////////loop array $NameandAge
if($nameinfirstarr == $nameinsecondarr){
echo .....; ////////print out the State, Name and Age
}
}
}