/** * Generate a list of married surnames that are not already present. * * @param string $xref * @param string $gedrec * * @return string[] */ private function surnamesToAdd($xref, $gedrec) { $wife_surnames = self::surnames($xref, $gedrec); $husb_surnames = array(); $missing_surnames = array(); preg_match_all('/^1 FAMS @(.+)@/m', $gedrec, $fmatch); foreach ($fmatch[1] as $famid) { $famrec = BatchUpdateModule::getLatestRecord($famid, 'FAM'); if (preg_match('/^1 MARR/m', $famrec) && preg_match('/^1 HUSB @(.+)@/m', $famrec, $hmatch)) { $husbrec = BatchUpdateModule::getLatestRecord($hmatch[1], 'INDI'); $husb_surnames = array_unique(array_merge($husb_surnames, self::surnames($hmatch[1], $husbrec))); } } foreach ($husb_surnames as $husb_surname) { if (!in_array($husb_surname, $wife_surnames)) { $missing_surnames[] = $husb_surname; } } return $missing_surnames; }