Remove Specific key value pair from PHP array
I have two key value pair arrays, one is the original, the other an array of key value pairs that need to be removed. I need to remove a specific combination, ie $removeArray would contain:
Array([Word] => 78)
I've tried:
foreach($removeArray as $key => $value){unset($originalArray[$key][$value]);}
This doesn't work at all. I need to remove based off an exact key value pair match.
EDIT:
Original
Array ( [distribution] => 25 [watch] => 25 [electricity] => 25 [timepiece] => 8 [wristwatch] => 25 [energy] => 8 [transmission] => 8 [clock] => 16 )
Remove
Array ( [timepiece] => 8 [energy] => 8 [watch] => 17 )
Result
Array ( [distribution] => 25 [watch] => 25 [electricity] => 25 [wristwatch] => 25 [transmission] => 8 [clock] => 16 )
NOTE:
[watch] => 25
is not affected, because it is not equal to[watch] => 17
Answer
Solution:
You can use
for that, that compares both the values and the keys:
Example code:
Result:
Answer
Solution:
try this
Answer
Solution:
You can check like: