Support the ongoing development of Laravel.io →
Views Blade

i want to acces the id from level_1

my array looks like this:

Array
(
    [id] => 85
    [id_world] => 1
    [key] => b_main
    [level] => 0
    [created_at] => -0001-11-30 00:00:00
    [updated_at] => -0001-11-30 00:00:00
    [level_1] => Array
        (
            [id] => 9
            [key] => b_main
            [created_at] => -0001-11-30 00:00:00
            [updated_at] => -0001-11-30 00:00:00
        )

    [level_2] => Array
        (
            [id] => 10
            [key] => b_main
            [created_at] => -0001-11-30 00:00:00
            [updated_at] => -0001-11-30 00:00:00
        )

    [level_3] => Array
        (
            [id] => 11
            [key] => b_main
            [created_at] => -0001-11-30 00:00:00
            [updated_at] => -0001-11-30 00:00:00
        )

)

my foreach looks like this (b is the array above):

@foreach ($a $b)
    {{ "<pre>"; print_r($b); echo "</pre>"; }}
    <tr>
        <th>
            {{{ $b['key'] }}}
        </th>
        <td>
            adsasd
        </td>
        <td>
            @{{ $b['level_1']['id'] }}
        </td>
        <td>
            adsasd
        </td>
    </tr>
@endforeach

the error i got:

Undefined index: level_1 (View: /var/www/core/app/views/asd/index.blade.php) 

so, how i can acces my id on level_1?

Last updated 3 years ago.
0
@foreach ($a as $b)

Missing 'as'

Last updated 3 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.