Ifrit's avatar
Level 2

Trying to access array offset on value of type int

I have an array that looks like this

array: {
    0 => 'Title 1',
    1 => 'Description 1'
}

The problem I'm having is when I do this in my blade file

@foreach($arrays as $array)
    {{ $array[0] }}
@endforeach 

I get this error

Trying to access array offset on value of type int

0 likes
3 replies
newbie360's avatar
@foreach($arrays as $element)
    {{ $element }}
@endforeach 
Ifrit's avatar
Level 2

But what if I just want the Title 1?

jlrdw's avatar
$data = [
    0 => 'Title 1',
    1 => 'Description 1'
];

// then

$data[0];

Where are you getting those results?

Please or to participate in this conversation.