Jump to content

Dynamically get $_POST


wemustdesign

Recommended Posts

I am using the Paypal ipn to add bought products to my database. So I have posted my products to Pyapl fine. I am having trouble getting the variables dy7namically in the IPN. I can do it manually fine like this:

 

$item_number1 = $_POST['item_number1'];

$item_number2 = $_POST['item_number2'];

....................

 

I need to dynamically create the above. I thought the while loop below would work but I am not sure if this is how you would do this, or if I have the correct syntax:

 

$dc=1;

while($dc <= $num_cart_items){

echo "$item_number$dc = $_POST['item_number$dc']";

$dc++;

 

Link to comment
https://forums.phpfreaks.com/topic/194323-dynamically-get-_post/
Share on other sites

<?php

$a['item_number1']='1111';
$a['item_number2']='2222';
$a['item_number3']='3333';
$a['item_number4']='4444';

$dc='1';
while($dc <=4) {
        ${"item_number{$dc}"} = $a["item_number$dc"];
        $dc++;
}

print $item_number1."<br>\n";
print $item_number2."<br>\n";
print $item_number3."<br>\n";
print $item_number4."<br>\n";

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.