<?php
$arr1=array("jol","pop","hari","john");//the array count is not limited to 4
$arr2=array('germany','america','holland','america');
?>
Now I want to link
Name: jol(1),pop(2),hari(3),john(2)
Address:germany(1),america(2),holland(3)
we get the name as pop(2) and john(2) because both are of same country
Assuming that the two arrays will always have the same number of entries, you can do this with a code like this one:
The first part of the loop stores indices of the first match for each country. The second part finds the corresponding index for each name.
Naturally, you’ll need to add error checking for cases when a country is not found for the user (e.g. the number of elements in arrays don’t match).