Are there alternative methods, like using HTML tables, for displaying hierarchical structures like family trees instead of generating graphics with PHP?

Displaying hierarchical structures like family trees can be achieved using HTML tables instead of generating graphics with PHP. By nesting table rows and cells, you can visually represent the relationships between family members. This method is simple, easy to implement, and can be customized using CSS for styling.

<?php
// Sample family tree data
$family_tree = [
    'Grandparent' => [
        'Parent 1' => [
            'Child 1',
            'Child 2'
        ],
        'Parent 2' => [
            'Child 3',
            'Child 4'
        ]
    ]
];

// Function to recursively generate HTML table rows for family tree
function generateFamilyTree($family_tree) {
    $html = '<table>';
    foreach ($family_tree as $key => $value) {
        $html .= '<tr><td>' . $key . '</td></tr>';
        if (is_array($value)) {
            $html .= '<tr><td>' . generateFamilyTree($value) . '</td></tr>';
        }
    }
    $html .= '</table>';
    return $html;
}

// Display the family tree
echo generateFamilyTree($family_tree);
?>