Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8742117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:26:35+00:00 2026-06-13T11:26:35+00:00

I have 2 arrays. 1st one is $people = array( ‘person1’ => array(‘name’ =>

  • 0

I have 2 arrays.
1st one is

 $people = array(
    'person1' => array('name' => 'Ted', 'Year' => '68'),
    'person2' => array('name' => 'Jane', 'Year' => '72'),
    'person3' => array('name' => 'James', 'Year' => '46'),
    'person4' => array('name' => 'Tim', 'Year' => '44'),
    'person5' => array('name' => 'Ann', 'Year' => '39'),
    'person6' => array('name' => 'Leyla', 'Year' => '45'),
    'person7' => array('name' => 'Lucy', 'Year' => '41'),
    'person8' => array('name' => 'Diana', 'Year' => '28'),
    'person9' => array('name' => 'Tony', 'Year' => '10'),
    'person10' => array('name' => 'Jane', 'Year' => '20'),
    'person11' => array('name' => 'Alex', 'Year' => '30'),
    'person12' => array('name' => 'Jane', 'Year' => '3'),
    'person13' => array('name' => 'Ted', 'Year' => '27'),
    'person14' => array('name' => 'Alex', 'Year' => '1'),
);

and the second one is

 $genTree = array(
    'families' => array(
        array(
            "mother" => 'person2',
            "father" => 'person1',
            'children' => array(
                'person3',
                'person4',
                'person5'
            )
        )
    ),
    'nextGeneration' => array(
        'families' => array(
            array(
                'mother' => 'person6',
                'father' => 'person3',
                'children' => array(
                    'person8',
                 ),
            ),
            array(
                'mother' => 'person7',
                'father' => 'person4',
                'children' => array(
                    'person9',
                    'person10'
                )
            ),
       ),
       'nextGeneration' => array(
           'families' => array(
                array(
                    'mother' => 'person8',
                    'father' => 'person11',
                    'children' => array(
                        'person12'
                    )
                ),
                array(
                    'mother' => 'person10',
                    'father' => 'person13',
                    'children' => array(
                        'person14'
                    )
                )
            ),
        ),
   ),
);

I need to get every family for each generation in new table data,
so it should be arrange as a family tree

I try to do next, but not what i need

    function nameValues($array){
    global $people; echo "<table border=1>";
    foreach($array as $key=>$value)
    {

        echo "<tr>";
        if(is_array($value))
        {
            nameValues($value);
        }else{

             echo "<td>".$key." ".$people[$value]['name']."</td>";echo "</tr>";

        }
    }
    echo "</table>";


}

thanks for help and explenation

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T11:26:36+00:00Added an answer on June 13, 2026 at 11:26 am

    I hope this will help

    echo nameValues($genTree);
    
    function nameValues($array){
        global $people;
    
        $table = '<table border="1">';
        foreach($array as $key => $value){
            if($key == 'families'){
                $table .= '<tr>';
                foreach($value as $familyKey => $familyValue){
                    $table .= '<td>';
                    $table .= '<table border="1">';
                    $table .= '<tr>';
                    $table .= '<td>Mother: </td><td>'.$people[$familyValue['mother']]['name'].'</td>';
                    $table .= '<td>Age: </td><td>'.$people[$familyValue['mother']]['Year'].'</td>';
                    $table .= '</tr>';
                    $table .= '<tr>';
                    $table .= '<td>Father: </td><td>'.$people[$familyValue['father']]['name'].'</td>';
                    $table .= '<td>Age: </td><td>'.$people[$familyValue['father']]['Year'].'</td>';
                    if(is_array($familyValue['children'])){
                        foreach($familyValue['children'] as $childrenKey => $childrenValue){
                            $table .= '<tr>';
                            $table .= '<td>Child: </td><td>'.$people[$childrenValue]['name'].'</td>';
                            $table .= '<td>Age: </td><td>'.$people[$childrenValue]['Year'].'</td>';
                            $table .= '</tr>';
                        }
                    }
                    $table .= '</tr>';
                    $table .= '</table>';
                    $table .= '</td>';
                }
                $table .= '</tr>';
            }else{
                $table .= nameValues($value);
            }
        }
        $table .= '</table>'; 
        return $table;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two arrays one like 1 | 1st name 2 | 2nd name
I have 3 arrays like this: 1st Array ( [0695] => Array ( [loan_number]
I have arrays like this. [11] => Array ( [transactioncurrencyid] => Array ( [!name]
I have an issue with the below array, where the 1st one (should be
I have 2 arrays in 2D, where the column vectors are feature vectors. One
I have 3 arrays, one has low value weight, the other high value weights,
so I have two arrays. one of them looks like this (it's values or
I have two database, 1st one is for Group and the 2nd one is
I have two arrays like this: [a] => Array ( [w] => 90 [h]
I have an array of dates in a one week range stored in an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.