Akshay K Nair
Akshay K Nair

Reputation: 1476

Laravel: Can't display array value in blade

I store json in my db and retrive it in decoded format using my model. I pass the value to a blade and tries to display a value from json there.

I dd($properties) and gets this:

array:1 [
  "like" => 10
]

This works: {{dd($properties["like"])}} gets correct integer value 10

But when I do {{$properties["like"]}} it returns "Cannot access offset of type string on string".

But $properties is not a string, coz when I {{$properties}}, it gives "htmlspecialchars(): Argument #1 ($string) must be of type string, array given" . {{gettype($properties)}} gives array.

Upvotes: 0

Views: 158

Answers (1)

toffeegz
toffeegz

Reputation: 88

use for loop

foreach($properties as $property) {
     $property["like"];
}

Upvotes: 1

Related Questions