Newbie to PHP.
Trying to output the results of an array inside a foreach loop. I have got the following code but I cannot understand what to do with it next.
Mainly;
- Where/how do I start and end the php statements?
- Is there a better way to format this code?
I want to make it as easy to understand and legible as possible.
I'm not sure how to echo
my rows within the specified html below?
My code so far;
<?php foreach ($userResults as $row) : ?>
<div class="row">
<ul class="list-group">
<li class="list-group-item">echo $row['user_id'] here</li>
<li class="list-group-item">echo $row['user_name'] here</li>
<li class="list-group-item">echo $row['user_email'] here</li>
</ul>
</div>
<?php endforeach; ?>
Any help or advice is appreciated.
?>
you jump out of PHP, so yourecho $row[...]
stuff is printing out literally, I'm guessing? You need to re-enter PHP or never leave it, if I'm understanding correctly. Technically, this is broken code, so your question might get closed. \$\endgroup\$