I'm trying to initialize iterations of variables that i'm sending to my server-side script. I don't want to enter each of them individually so I am wondering if what I have is valid syntax or if there is a more efficient way of doing this.
for($i = 1; $i <=10; $i++){
$itemNumber.$i = $_POST['title'.$i];
$itemType.$i = $_POST['type'.$i];
$itemDescription.$i = $_POST['description'.$i];
$itemAmount.$i = $_POST['amount'.$i];
$itemComments.$i = $_POST['comments'.$i];
}
My expected output is:
$itemNumber1 = $_POST['title1'];
$itemType1 = $_POST['type1'];
...
after the first iteration and etc.