Jump to content

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";

?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.