I have an array $minus
array(3) { [0]=> string(6) "people"
[1]=> string(7) "friends"
[2]=> string(8) "siblings"
}
And I have an array $user
array(3) { ["people"]=> string(3) "100"
["friends"]=> string(2) "10"
["siblings"]=> string(2) "57"
}
I can get the values of $user
by using the values of $minus
like,
echo $user[$minus[0]] . ', ' . $user[$minus[1]] . ', ' . $user[$minus[2]];
// Would echo: 100, 10, 57
But how can I get the values of $user
by using the values of $minus
into a new array, the new array should be like,
array(3) { [0]=> string(3) "100"
[1]=> string(2) "10"
[2]=> string(2) "57"
}
I have tried using foreach
loops but can never get it right?