$potential) { if (isset($potential["family"]) && count($potential["family"]["children"]) > 0 && in_array($id, $potential["family"]["children"]) && $potential["sex"] !== "F") { $found = true; $dad = $potential["famname"] . " " . $potential["surname"]; $dadId = $potid; } } if (!$found) { $dad = "???"; } // Mother $found = false; foreach ($data as $potid => $potential) { if (isset($potential["family"]) && count($potential["family"]["children"]) > 0 && in_array($id, $potential["family"]["children"]) && $potential["sex"] === "F") { $found = true; $mom = $potential["famname"] . " " . $potential["surname"]; $momId = $potid; } } if (!$found) { $mom = "???"; } // Mother's data if (isset($momId)) { // Father $found = false; foreach ($data as $potid => $potential) { if (isset($potential["family"]) && count($potential["family"]["children"]) > 0 && in_array($momId, $potential["family"]["children"]) && $potential["sex"] !== "F") { $found = true; $momDad = $potential["famname"] . " " . $potential["surname"]; $momDadId = $potid; } } if (!$found) { $momDad = "???"; } // Mother $found = false; foreach ($data as $potid => $potential) { if (isset($potential["family"]) && count($potential["family"]["children"]) > 0 && in_array($momId, $potential["family"]["children"]) && $potential["sex"] === "F") { $found = true; $momMom = $potential["famname"] . " " . $potential["surname"]; $momMomId = $potid; } } if (!$found) { $momMom = "???"; } } else { $momMom = "???"; $momDad = "???"; } // Father's data if (isset($dadId)) { // Father $found = false; foreach ($data as $potid => $potential) { if (isset($potential["family"]) && count($potential["family"]["children"]) > 0 && in_array($dadId, $potential["family"]["children"]) && $potential["sex"] !== "F") { $found = true; $dadDad = $potential["famname"] . " " . $potential["surname"]; $dadDadId = $potid; } } if (!$found) { $dadDad = "???"; } // Mother $found = false; foreach ($data as $potid => $potential) { if (isset($potential["family"]) && count($potential["family"]["children"]) > 0 && in_array($dadId, $potential["family"]["children"]) && $potential["sex"] === "F") { $found = true; $dadMom = $potential["famname"] . " " . $potential["surname"]; $dadMomId = $potid; } } if (!$found) { $dadMom = "???"; } } else { $dadMom = "???"; $dadDad = "???"; } ?> Tree maker 🌳