On the html page there is a multiple select list, for example

<form action="" method="post"> <select name="multi[]" multiple> <option value="Арбуз">Арбуз</option> <option value="Дыня">Дыня</option> <option value="Груша">Груша</option> </select> <input name="submit" type="submit" /> </form> 

Here we took the data:

 <?php if (isset($_POST['submit'])) { foreach ($_POST['multi'] as $selectedOption) echo $selectedOption.","; } ?> 

For example, I chose all 3 (there may be as many as possible) options, how can I output all of them into separate variables? For example multi (1), multi (2), multi (3).

  • That doesn't make the slightest sense. why did you decide that you need it? - Ipatiev
  • Can I not prove that my question is important and necessary, at least for me personally? - Alex Spiridonov
  • one
    It is possible, but it is desirable to clarify your question. At your leisure, read this joke . There, the dude also believed that he was smarter than everyone and should not prove anything to anyone. And the problem in the end may simply be in the wrong terminology - Ipatyev
  • But programming is not an operation, everything can be rolled back. Well, people somehow store the data from the multiple select. Suppose that in one variable. And how can I get 1 option from this variable, how to work with it? For example, I have a melon, a watermelon, a pear. I want to get a watermelon and bring it to the screen - Alex Spiridonov
  • And output echo $_POST['multi'][0]; . As I expected, no separate variable is required for this. - Ipatiev

0