What is the best way to transfer data from a list to an input form in PHP?

When transferring data from a list to an input form in PHP, you can use a loop to iterate over the list items and populate the input fields with the data. You can achieve this by assigning each list item's value to the corresponding input field's value attribute.

<?php
$list = ["Item 1", "Item 2", "Item 3"];
?>

<form action="process_form.php" method="post">
    <?php foreach($list as $item): ?>
        <input type="text" name="item[]" value="<?php echo $item; ?>">
    <?php endforeach; ?>
    <button type="submit">Submit</button>
</form>