Hi All,
Been trying to figure this out. I have 2 arrays. The first has a number of keys and values. The 2nd just has the keys. I want to use the 2nd array to return the appropriate values from the 1st array based on the key.
$salespeople = array {
0=>"Everyone",
1=>"Bob",
2=>"Mary",
3=>"Sam",
4=>"Linda",
5=>"Peter",
6=>"John");
$newvalues = "1|3|5"; # stored in DB like this
$savedArray = explode("|", $newvalues);
So I want to compare the savedArray and the salespeople and get back Bob, Sam and Peter.
I was thinking of counting the number of items in savedArray and then doing for loop such as:
$count = count($savedArray);
for ($i = 0; $i <= $count - 1; $i++)
{
echo $salespeople[$savedArray[$i]];
}
Is there a more efficient way of doing this?
Thanks in advance,
Cent