Here’s my full code snippet for this function:
if (in_array($details['Name'], $masterList[$key]) === false && preg_match('/(Delta Dental)[ ]([a-zA-Z]*[ ]*)+/', $details['Name']) === 1) {
if (preg_match("/(State Employee Plan)/", $details['Name'])) {
$dd[][] = "State Employee Plan";
} else if (preg_match("/(Wilson McShane)/", $details['Name'])) {
$dd[][] = "Wilson McShane";
} else {
$dd[][] = trim(strrchr($details['Name'], ' '));
}
if (count($dd) > 4) {
for ($i = 0; $i < count($dd); $i++) {
$merge = array_merge($merge, $dd[$i]);
}
$unique = array_values(array_unique($merge));
$merge = array();
if ($unique[0] === "State Employee Plan") {
$shifted = array_shift($unique);
array_push($unique, $shifted);
}
sort($unique);
array_unshift($unique, "Delta Dental");
$newVal = $unique[0] . ' ' . $unique[1];
for ($j = 2; $j < count($unique); $j++) {
$newVal .= '/' . $unique[$j];
}
if ($newVal) {
array_push($masterList[$key], $newVal);
$newVal = '';
$unique = array();
$dd = array();
}
}
}`
The count($dd) > 4 changes between each GroupName so I need a way to count the GroupName instances before combining the names.
The error is that some names are combining with others, so some results are “Delta Dental PPO/PPO/Premier/Premier”.
Thanks!