Reputation: 51
Hello I have the following variable in my PHP:
$art= [
'places' => ['America','Paris','Italy','Japan'],
'photographer' => ['Samantha','Hannah','David','Albert'],
];
I am just trying to output 'places' only into my HTML code. Keep getting "Illegal String Offset" warning.
Why is my following code not working?
<?php foreach($art as $value): ?>
<?= $value['places'] ?>
<?php endforeach ?>
Upvotes: 0
Views: 35
Reputation: 333
<?php foreach ($art["places"] as $value): ?>
<?= $value ?>
<?php endforeach; ?>
you should loop the $art["places"];
Upvotes: 1