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 ?>
<?php foreach ($art["places"] as $value): ?>
<?= $value ?>
<?php endforeach; ?>
you should loop the $art["places"];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.