I’m using an online shopping cart which takes items ordered and passes their unique ID through the URL to a process.php page. So the URL would look something like
process.php?code_1=231&code_2=532&code_3=342
Another code_x=xxx is generated for each item ordered. On the process.php page, how would I create an array to get the values of the code_x without knowing how many items are ordered?
This problem is much better solved by changing the names of the elements in your form to
code[].For example, where you now have let’s say
You would change that to
After doing this,
$_GET['code']will be an array which contains all the values from the text boxes as its items.Update:
If you cannot control the names of the incoming parameters, you need to parse manually. Here’s how I would do it: