I would like some guidance with regards to how to display data in an array that may or may not be multi-dimensional.

I currently use this -

```
if (count($array) == count($array, COUNT_RECURSIVE)){
    echo $array['Name'];
    echo $array['Surname'];
    echo $array['Email'];
}else{
    foreach($res as $val){
        echo $val['Name'];      
        echo $val['Surname'];
        echo $val['Email'];
    }
}

```

This work ok, however, it does mean a lot of duplicate code if there are multiple fields to display.

Is there a way to condense the code so there is no duplication?