Flash Messages Array in PHP

It might be the case that we need to display not one flash message, but several. In this case, we need to make an array of messages.

Let the first message be written on the page page1.php:

page1.php<?php
  session_start();
  $_SESSION['flash'][] = 'message 1';
?>

And the second message is written on the page page2.php:

page2.php<?php
  session_start();
  $_SESSION['flash'][] = 'message 2';
?>

Let's display these messages on the page index.php and clear the array of messages:

php<?php
  session_start();
  
  if (!empty($_SESSION['flash'])) {
    foreach ($_SESSION['flash'] as $flash) {
      echo $flash;
    }
    
    $_SESSION['flash'] = []; // clear messages
  }
?>
Задание 1

Implement the described flash messages. Check their operation.