I am trying to save an array to $_POST['fetched_devices_array'] = array() and when I try to echo it inside the HTML form it prints the elements of it but when I try to send it to PHP after submission it is empty-I tried printing it after submission when I was receiving it in PHP.
Here is the code where I am setting it:
 <tbody>
        <form action="" method="POST">
            <?php
            echo "<table>
                <tr>
                <th>Customer ID</th>
                <th>Report ID</th>
                <th>Report message</th>
                <th>Device</th>
                <th>Device no.</th>
                <th>Barcode</th>
                <th>IMEI</th>
                <th>Sale-date</th>
                </tr>";
            $_POST['fetched_devices_array'] = array();
            //$_SESSION['countable_array'] = [];
            while ($row2 = $clientUsername->fetch_assoc()) {
                $_SESSION['cl_username'] = $row2["username"];
                while ($row = $message->fetch_assoc()) {
                    $_SESSION['accept'] = $row["acceptance"];
                    $_SESSION['client_comment'] = $row["message"];
                    $_SESSION['name'] = $row["name"];
                    $_SESSION['sales_date'] = $row["sales_date"];
                    $_SESSION['date_sent'] = $row["date_sent"];
                    $arr = $row['device_id'];
                    array_push($_POST['fetched_devices_array'], $arr);
                    ?>
            <?php if ($row['acceptance'] == 3) {
                        if ($message->num_rows > 1) {
                            echo "<tr> <td>
                              " . '<input type=checkbox name=devices[] value=' . $row['dev_id'] . '>' . "
                        </td> <td>" . $cus_id . " </td> <td>" . $rep_id . "</td> <td>" . $_SESSION['client_comment'] . "</td> <td>" . $_SESSION['name'] . "</td> <td>" . $row["device_no"] . "</td> <td>" . $row["barcode"] . "</td> <td>" . $row["serial_imei"] . "</td> <td>" . $row["serial_no"] . "</td> <td>" . $row["sales_date"] . "</td></tr>";
                            echo "</table>";
                        } else {
                            echo "<tr>
               <td>" . $cus_id . " </td> <td>" . $rep_id . "</td> <td>" . $_SESSION['client_comment'] . "</td> <td>" . $_SESSION['name'] . "</td> <td>" . $row["device_no"] . "</td> <td>" . $row["barcode"] . "</td> <td>" . $row["serial_imei"] . "</td> <td>" . $row["serial_no"] . "</td> <td>" . $row["sales_date"] . "</td></tr>";
                            echo "</table>";
                        }
                    } else {
                        echo "<tr>
           <td>" . $cus_id . " </td> <td>" . $rep_id . "</td> <td>" . $_SESSION['client_comment'] . "</td> <td>" . $_SESSION['name'] . "</td> <td>" . $row["device_no"] . "</td> <td>" . $row["barcode"] . "</td> <td>" . $row["serial_imei"] . "</td> <td>" . $row["serial_no"] . "</td> <td>" . $row["sales_date"] . "</td></tr>";
                        echo "</table>";
                    }
                }
            }
            ?>
            <?php while ($row3 = $acceptance->fetch_assoc()) {
                if ($row3['acceptance'] == '3') { ?>
                    <div class="input-group">
                        <label>If reject, please write the reason below:</label>
                        <textarea name="admin_comment" rows="7" cols="27"><?php echo $admin_comment; ?></textarea>
                    </div>
                    <p>
                        Return device to :
                        <?php
                                $sql = "SELECT id, username, user_type FROM users";
                                $result = $db->query($sql);
                                echo "<select name='device_manufacturer'>";
                                $nothing = "Nothing selected";
                                echo "<option value='" . $nothing . "'>" . $nothing . "</option>";
                                while ($row = $result->fetch_assoc()) {
                                    if ($row['user_type'] === 'manufacturer' || $row['user_type'] === 'admin') {
                                        echo "<option value='" . $row['id'] . "'>" . $row['username'] . "</option>";
                                    }
                                }
                                echo "</select>";
                                ?>
                    </p>
                    <input type="submit" name="rejected" value="Reject report" />
                    <input type="submit" name="accepted" value="Accept report" />
        </form>
    </tbody>
Here I am receiving:
$fetched_devs = $_POST['fetched_devices_array'];
