I get the error: Illegal string offset 'name' Why is this occurring?
Because the first element you are iterating over is $vars['name']
, which has the value 'Hello World'
, which is a string. And 'Hello World'['name']
just doesn't work.
Looks like you want to iterate over $vars['products']
only.