Question: Right now i got an array which has some sort of information and i need to create a table from it. e.g.

```
Student{
      [Address]{
              [StreetAddress] =>"Some Street"
              [StreetName] => "Some Name"
      }
      [Marks1] => 100
      [Marks2] => 50
    }

```

Now I want to create database table like which contain the fields name as :

```
Student_Address_StreetAddress
Student_Address_StreetName
Student_Marks1
Student_Marks2

```

It should be recursive so from any depth of array it can create the string in my format.

Answer: 
Something like this maybe?

```
$schema = array(
    'Student' => array(
        'Address' => array(
            'StreetAddresss' => "Some Street",
            'StreetName' => "Some Name",
        ),
        'Marks1' => 100,
        'Marks2' => 50,
    ),
);

$result = array();

function walk($value, $key, $memo = "") {
    global $result;
    if(is_array($value)) {
        $memo .= $key . '_';
        array_walk($value, 'walk', $memo);
    } else {
        $result[] = $memo . $key;
    }
}

array_walk($schema, 'walk');

var_dump($result);

```

I know globals are bad, but can't think of anything better now.
```
function getValues($dataArray,$strKey="")
{
    global $arrFinalValues;

    if(is_array($dataArray))
    {
        $currentKey = $strKey;
        foreach($dataArray as $key => $val)
        {
            if(is_array($val) && !empty($val))
            {   
                getValues($val,$currentKey.$key."_");
            }
            else if(!empty($val))
            {
                if(!empty($strKey))
                    $strTmpKey = $strKey.$key;
                else
                    $strTmpKey = $key;
                $arrFinalValues[$strTmpKey]=$val;
            }
        }
    }
}

```