searching through IPN string to get item_name for each item

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
eoin.ahern@mycit.ie
Forum Newbie
Posts: 15
Joined: Mon Mar 05, 2012 11:48 am

searching through IPN string to get item_name for each item

Post by eoin.ahern@mycit.ie »

hi therer :D . iam looking to try and find out how i would go about searching through a string to get back the values posted back to me from paypal to my IPN script. for now i just want to get the item name for each item sold (could be any number) im just not sure how to do it. ive looked at strpos() but im not sure exactly how i should use that. if anyone could point me in the direction of a good tutorial for this type of thing that would be great! :D
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: searching through IPN string to get item_name for each i

Post by Celauran »

PayPal IPNs are sent as a POST request, so you should be able to access $_POST['item_name'] directly. Where, specifically, are you running into problems?
eoin.ahern@mycit.ie
Forum Newbie
Posts: 15
Joined: Mon Mar 05, 2012 11:48 am

Re: searching through IPN string to get item_name for each i

Post by eoin.ahern@mycit.ie »

em yeah i know i can access them directly. thats fine, its just when i dont know the number of items i want to grab all item names from the string i make from the IPN reply. not sure how to look through the string grab each item_name1 item_name2 ........ etc and put them in an array possibly. im not great with string maniupulation in php as im pretty fresh to the language!
eoin.ahern@mycit.ie
Forum Newbie
Posts: 15
Joined: Mon Mar 05, 2012 11:48 am

Re: searching through IPN string to get item_name for each i

Post by eoin.ahern@mycit.ie »

can preg_grep() be used to search for a word?
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: searching through IPN string to get item_name for each i

Post by Celauran »

I was going to suggest preg_match_all()
eoin.ahern@mycit.ie
Forum Newbie
Posts: 15
Joined: Mon Mar 05, 2012 11:48 am

Re: searching through IPN string to get item_name for each i

Post by eoin.ahern@mycit.ie »

cool! ill have a read up on that also! thanks heres what i have so far

$eoinsvars;
foreach ($_POST as $key => $value)
{
urldecode($value);
$eoinsvars.="$value";

}

this gives me back all the values, great! what i want to do now is search string items_name which is a key values get its value and put it in an array!
eoin.ahern@mycit.ie
Forum Newbie
Posts: 15
Joined: Mon Mar 05, 2012 11:48 am

Re: searching through IPN string to get item_name for each i

Post by eoin.ahern@mycit.ie »

so its actually an array in searching not a string this should make things a lot easier
eoin.ahern@mycit.ie
Forum Newbie
Posts: 15
Joined: Mon Mar 05, 2012 11:48 am

Re: searching through IPN string to get item_name for each i

Post by eoin.ahern@mycit.ie »

here is all i had to do. was pretty easy after all.

$eoinsarray = array();

foreach ($_POST as $key => $value)
{
urldecode($value);
if (strpos($key,'item_name') !== false)
{

$eoinsarray [] = $value;

}



}
Post Reply