我可以使用一堆输入标签来发送由PHP添加的不同数字吗?

I really don't think it's a great idea or a smart one to use an insane amount of input tags, so is it possible to have a bunch of different input tags that would all be submitted as one added number? Or would it at least be possible to have some PHP that would read every single input's content, without putting every single one in the code?

(Example: Bob types 3, 9, and 18 in three text input areas on a form and sends it. The PHP then adds them together and returns the result.)

Current code:

<!DOCTYPE html>
<head>
<title>Grocery Calculator 1.0</title>
</head>
<body>
<h1>This is a grocery prices calculator. Love it pls</h1>
<form action="" method="put">
Item 1 Price: <input type="number" name="price1">
Number of Item 1: <input type="number" name="numbe1">
Item 2 Price: <input type="number" name="price2">
Number of Item 2: <input type="number" name="numbe2">
Item 3 Price: <input type="number" name="price3">
Number of Item 3: <input type="number" name="numbe3">
Tax Rate (must be numerical, based on percentage. Begin with "."):       
<input type="number" name="tax">
</form>

<h1>yer total:</h1>
<?php 
$gprice1 = $_GET["price1"] * $_GET["numbe1"];
$gprice2 = $_GET["price2"] * $_GET["numbe2"];
$gprice3 = $_GET["price3"] * $_GET["numbe3"];

$gSubTotal1 = $gprice1 + $gprice2 + $gprice3;
$gTaxTotal1 = $gSubTotal1 * $_GET["tax"];

echo $gTaxTotal1;
?>

But I don't really like that code, because the calculator would have to have a massive number of form tags and the php itself would have to be written to accommodate all of it.

In your view, name the inputs with array syntax:

Item 1 Price: <input type="number" name="price[]">
Number of Item 1: <input type="number" name="numbe[]">
Item 2 Price: <input type="number" name="price[]">
Number of Item 2: <input type="number" name="numbe[]">
Item 3 Price: <input type="number" name="price[]">
Number of Item 3: <input type="number" name="numbe[]">

This makes it easy to add a JavaScript-powered button that adds more textboxes to the screen if you don't want to hard-code them upfront or don't know in advance how many are needed.

In your back-end code, the values will be accessible as such:

$prices = $_POST['price'];
$quantities = $_POST['numbe'];
$total = 0;

foreach ( $prices as $key => $p ) {
  $total += $p * $quantities[$key];
}

print "The total is ". $total;