how to remove only real duplicates from preg_match output?
问题 Yes I know array_unique function, but the thing is that match might have a legitimate duplicates in my search term for example: $str = "fruit1: banana, fruit2: orange, fruit3: banana, fruit4: apple, fruit5: banana"; preg_match("@fruit1: (?<fruit1>\w+), fruit2: orange, fruit3: (banana), fruit4: (?<fruit4>apple), fruit5: (banana)@",$str,$match); array_shift($match); // I dont need whole match print_r($match); output is: Array ( [fruit1] => banana [0] => banana [1] => banana [fruit4] => apple [2