PHP:
<?php
session_start();
$postDaEliminare = $_POST['postDaEliminare'];
$postDaEliminare = str_replace('"', "", $postDaEliminare);
$msg = \array_diff($postDaEliminare);
echo $postDaEliminare;
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div class="diario">
<center>
<h1>DIARIO</h1>
<center>
<div align="left">
<form action="testDiario.php" method="post">
<textarea name="msg" id="msg" cols="30" rows="10"></textarea>
<input type="submit" value="invia">
</form>
</div>
<div>
<?php
$data = date("d/m/Y");
$time = date("h:i A");
if(isset($_POST['msg'])) {
if (!isset($_SESSION['msg'])) {
$msg = array();
$i = 0;
}
else {
$msg = $_SESSION['msg'];
$i = count($msg);
}
$msg1 = $_POST['msg'];
$msg[$data . ", " . $time] = $msg1;
print_r($msg);
$_SESSION['msg'] = $msg;
}
foreach ($msg as $key => $value) {
$indice = $key;
$mes = $value;
$post = "
<p class=\"data inline\">$indice</p>
<p class=\"post inline\">$mes</p>
";
echo($post);
}
?>
</div>
<div>
<form action="testDiario.php" method="post">
<select name="postDaEliminare">
<?php
foreach ($msg as $key => $value) {
$indice = $key;
echo('<option class="width" value="' . $value . '">"' . $indice . '"</option>');
}
?>
</select>
<input type="submit" value="ELIMINA POST">
</form>
</div>
</body>
</html>
PHP:
name="postDaEliminare"