在for cicle上创建具有"$ i"值的变量

use*_*569 1 php forms for-loop

<form>
  <?php
    for($i=1; $i<=3; $i++){
       print '<input ... name="'.$until.$i.'">...
   print '<input ... name="'.$quantity.$i.'">...
}
  ?>
</form>
Run Code Online (Sandbox Code Playgroud)

是否有可能用于:

for($p=1; $p<=3; $p++){

    $until.$p = $_POST['until'.$p]; // not required
    $quantity.$p = $_POST['quantity'.$p]; // required
}
Run Code Online (Sandbox Code Playgroud)

创建具有这些名称的变量?

$until1
$quantity1
...
$until3
$quantity3
Run Code Online (Sandbox Code Playgroud)

我的解决方案显然不会起作用......

Cez*_*cik 5

请改用数组.那你可以$until[$p]举个例子.