How can i show/view the property "people" only of multiple objects that stored in a session variable. I'm having a warning that said "Warning: Attempt to read property "people" on string". I tried foreach and used echo $log->people but no luck. Thanks
Screenshot of Error/Warning i received

Here is where i want to view/show only the propert "people":
<?php
session_start();
$current_count_inside = $_SESSION['inside'];
$current_count_outside = $_SESSION['outside'];
$current_count = $_SESSION['count'];
$data = $_SESSION['logs'];
foreach ($data as $log) {
echo $log->people . "<br>";
}
echo "<br>";
echo "<br>";
echo "<br>";
echo "<br>";
echo "inside = " . $current_count_inside . "<br>";
echo "outside = " . $current_count_outside . "<br>";
echo "count = " . $current_count . "<br>";
?>
Here is where i have my class Log and store new objects(Log) in to a session.
<?php
session_start();
class Log
{
public $people;
public $enter;
public $timestamp;
public $location;
public function __construct($people, $enter, $timestamp, $location)
{
$this->people = $people;
$this->enter = $enter;
$this->timestamp = $timestamp;
$this->location = $location;
}
}
if (isset($_POST['submit'])) {
if ($_POST['people'] <= 0) {
return header("Location: index.php");
}
if ($_POST['people'] == "inside") {
if ($_POST['people'] + $_SESSION['inside'] >= 50) {
return header("Location: index.php");
}
}
$new_log = new Log($_POST['people'], true, date("Y/m/d"), $_POST['location']);
$_SESSION['logs'][] = serialize($new_log);
if ($_POST['location'] == "inside") {
$_SESSION['inside'] = $_SESSION['inside'] + $_POST['people'];
$_SESSION['count'] = $_SESSION['count'] + $_POST['people'];
}
if ($_POST['location'] == "outside") {
$_SESSION['outside'] = $_SESSION['outside'] + $_POST['people'];
$_SESSION['count'] = $_SESSION['count'] + $_POST['people'];
}
header('Location: historiek.php');
}
if (isset($_POST['remove'])) {
if (intval($_SESSION['count']) <= 0 || intval($_SESSION['count']) - $_POST['remove_people'] < 0) {
$_SESSION['errors'] = "Probleem";
return header("Location: index.php");
}
$new_log = new Log($_POST['remove_people'], false, date("Y/m/d"), $_POST['location']);
$_SESSION['logs'][] = serialize($new_log);
if ($_POST['location'] == "inside") {
$_SESSION['inside'] = $_SESSION['inside'] - $_POST['remove_people'];
$_SESSION['count'] = $_SESSION['count'] - $_POST['remove_people'];
}
if ($_POST['location'] == "outside") {
$_SESSION['outside'] = $_SESSION['outside'] - $_POST['remove_people'];
$_SESSION['count'] = $_SESSION['count'] - $_POST['remove_people'];
}
header('Location: historiek.php');
}