I did look up this error and people say that it is caused by an empty array, but as you can see, I have entries for my array. Or that the variable isn't an array, which it is. I am unsure as to why this doesn't work. Any help would be greatly appreciated.
<? php
$posts = array();
$posts[0] = array(
'user' => 'Bob',
'message' => 'This is a post',
'image' => 'image/picture.jpg',
'date' => '20/4/17');
$posts[1] = array(
'user' => 'James',
'message' => 'This is also a post',
'image' => 'image/picture.jpg',
'date' => '20/4/15');
$posts[2] = array(
'user' => 'Steve',
'message' => 'This is also also a post',
'image' => 'image/picture.jpg',
'date' => '20/4/13');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Social Media</title>
<link rel="stylesheet" href="style/style.css">
</head>
<body>
<h1> Social Media </h1>
<?php foreach ($posts as $post){?>
<p>
<?= $post['user'] ?>
<?= $post['message'] ?>
<?= $post['date'] ?>
<?= $post['image'] ?>
</p>
<?php } ?>
</body>
</html>