Array to string conversion in html body


This Content is from Stack Overflow. Question asked by Rollo

I need help with this PHP code as I try to implement it into my html body I get an array to string conversion error.

I came up with this, I want to print out the unordered list without concatenations.

<?php foreach($links as $title):?>
            <a href = "<?= $links ?>"><?= $title ?></a>
 <?php endforeach ?>

I made this code up from this hashes of arrays.

$links = [
    ['title' => 'Slack', 'href' => ''],
    ['title' => 'Google','href' => ''],
    ['title' => 'Stack', 'href' => '']


Check the Answers

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?