I have an array $dataand need to filter it based on another array $clr. I did this with help foreachand decided my goal, but I am looking for the best way, for example mapor filter. I tried:
$clr = [1, 2, 4, 6, 8, 13, 21];
$data = [2, 3, 8];
foreach($clr as $val)
{
if(($key = array_search($val, $data)) !== false) unset($data[$key]);
}
print '<pre>';
print_r($data);
Any of your suggestions will be appreciated.
source
share