Well, you do a foreach on the $tasks variable. However, if $tasks is not an array this won't work.
Can you show us the code where you assign the value to $tasks?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi guys,
I'm new to programming. If I need to put down more info, please let me know a command
Warning: Invalid argument supplied for foreach() in /Users/gurinderkhabra/Desktop/php-learning/index.view.php on line 10
Here is the command
Document<ul>
<?php foreach ($tasks as $task) : ?> <! -- this is line 10 -->
<li>
<?php if ($task->completed) : ?>
<strike><?= $task->description; ?></strike>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
</body>
</html>
Please or to participate in this conversation.