循环嵌套循环

I have an array that looks like this except with over 40 more

Array
(
    [0] => stdClass Object
        (
            [id] => 1
            [name] => name
            [cost] => 20
            [firstname] =>
                (
                    [0] => first 1
                    [1] => first 2
                )
            [lastname] =>
                (
                    [0] => last 1
                    [1] => last 2
                )
            [username] =>
                (
                    [0] => username 1
                    [1] => username 2
                )
        )
    [0] => stdClass Object
        (
            [id] => 1
            [name] => name
            [cost] => 20
            [firstname] =>
                (
                    [0] => first 1
                    [1] => first 2
                )
            [lastname] =>
                (
                    [0] => last 1
                    [1] => last 2
                )
            [username] =>
                (
                    [0] => username 1
                    [1] => username 2
                )
        )
(

I am doing something like this to get the non nested arrays:

foreach($data as $row){
    echo $row->id
}

but what would I do to get the nested arrays? I wanna be able to display them as:

firstname lastname

username

foreach($data as $row){
    echo $row->firstname[0] . ' ' . $row->lastname[0] . '<br/>' . $row->username[0];
}

edit:

You should organize your array a bit better, if these are people who did product reviews:

Array
(
    [0] => stdClass Object
        (
            [id] => 1
            [name] => name
            [cost] => 20
            [reviews] => Array(
                [0]=>
                    (
                        [firstname] => "Bob"
                        [lastname] => "Jacob"
                        [username] => "bobjacob543"
                    )
                [1] = >
                    (...
            )
        )
    [0] => stdClass Object
        (

Then you can do

foreach($data as $row){
    foreach($row->reviews as $review){
        echo $review->firstname . ' ' . $review->lastname . '<br/>' . $review->username;
    }
    ...
}