In order to import database data with ease, I have tried to write some php code in order to help me out. I have 2 arrays, "list" wich is regular aray. Other "order1" is an associative array. I'm trying to compare value of first with keys of second to make list that I need.. Something like multi find and replace..
array: list
[0] => Apple
[1] => Apple
[2] => Apple
[3] => Apple
[4] => Bannana
[5] => Mango
[6] => Mango
[7] => Mango
[8] => Mango
[9] => Mango
[10] => Pear
[11] => Pear
[12] => Pear
[13] => Pear
[14] => Pineaple
[15] => Strawberry
[16] => Strawberry
[17] => Watermelon
[18] => Watermelon
[19] => Watermelon
[20] => Watermelon
array: order1
[Apple] => 1
[Bannana] => 2
[Mango] => 3
[Pear] => 4
[Pineaple] => 5
[Strawberry] => 6
[Watermelon] => 7
I want to get:
1
1
1
1
2
3
3
3
3
3
4
4
4
4
5
6
6
7
7
7
7
But..
$final=array();
foreach($list as $keyl => $valuel){
foreach($order1 as $keyo => $valueo){
if($valuel==$keyo) {
$final[].=$valueo;
}
}
}
print_r($final);
gets me just 7, last element..
Something wrong with recursion/life of var? But I can't seem to get it..