private function deformatNVP($nvpstr)
    {
        $intial          = 0;
        $nvpArray        = array();
        $paymentRequests = array();
        while(strlen($nvpstr)){
            //postion of Key
            $keypos = strpos($nvpstr,'=');

            //position of value
            $valuepos = strpos($nvpstr,'&') ? strpos($nvpstr,'&') : strlen($nvpstr);

            /*getting the Key and Value values and storing in a Associative Array*/
            $keyval = urldecode(substr($nvpstr, $intial, $keypos));
            $valval = urldecode(substr($nvpstr, $keypos+1, $valuepos-$keypos-1));

            //decoding the response
            $matches = array();
            if(preg_match("/^(L_PAYMENTREQUEST|PAYMENTREQUEST|L_PAYMENTINFO|PAYMENTINFO)_([0-9])_/", $keyval, $matches)) {
                $idx            = $matches[2];
                $newParentKey   = str_replace("L_", "", $matches[1]);
                if(!isset($nvpArray[$newParentKey])) {
                    $nvpArray[$newParentKey] = array();
                    $nvpArray[$newParentKey][$idx] = array();
                }

                //preserve L_ to indicate multiple values
                $keyval  = str_replace("{$newParentKey}_{$idx}_", "", $keyval);
                $targetArray =& $nvpArray[$newParentKey][$idx];
            } else {
                $targetArray =& $nvpArray;
            }

            if(false !== strpos($keyval, "L_")) {
                list($subNum, $subParentKey, $subKey) = $this->extractKeyValues($keyval);

                if(!isset($targetArray[$subParentKey])) {
                    $targetArray[$subParentKey] = array();
                    $targetArray[$subParentKey][$subNum] = array();
                }

                $targetArray[$subParentKey][$subNum][$subKey] = $valval;
            } else {
                $targetArray[$keyval] = $valval;
            }

            $nvpstr = substr($nvpstr, $valuepos+1, strlen($nvpstr) );
        }

        return array_merge($nvpArray, $paymentRequests);
    }
private function deformatNVP($nvpstr)
    {
        $intial          = 0;
        $nvpArray        = array();
        $paymentRequests = array();
        while(strlen($nvpstr)){
            //postion of Key
            $keypos = strpos($nvpstr,'=');

            //position of value
            $valuepos = strpos($nvpstr,'&') ? strpos($nvpstr,'&') : strlen($nvpstr);

            /*getting the Key and Value values and storing in a Associative Array*/
            $keyval = urldecode(substr($nvpstr, $intial, $keypos));
            $valval = urldecode(substr($nvpstr, $keypos+1, $valuepos-$keypos-1));

            //decoding the response
            $matches = array();
            if(preg_match("/^(L_PAYMENTREQUEST|PAYMENTREQUEST|L_PAYMENTINFO|PAYMENTINFO)_([0-9])_/", $keyval, $matches)) {
                $idx            = $matches[2];
                $newParentKey   = str_replace("L_", "", $matches[1]);
                if(!isset($nvpArray[$newParentKey])) {
                    $nvpArray[$newParentKey] = array();
                    $nvpArray[$newParentKey][$idx] = array();
                }

                //preserve L_ to indicate multiple values
                $keyval  = str_replace("{$newParentKey}_{$idx}_", "", $keyval);
                $targetArray =& $nvpArray[$newParentKey][$idx];
            } else {
                $targetArray =& $nvpArray;
            }

            if(false !== strpos($keyval, "L_")) {
                list($subNum, $subParentKey, $subKey) = $this->extractKeyValues($keyval);

                if(!isset($targetArray[$subParentKey])) {
                    $targetArray[$subParentKey] = array();
                    $targetArray[$subParentKey][$subNum] = array();
                }

                $targetArray[$subParentKey][$subNum][$subKey] = $valval;
            } else {
                $targetArray[$keyval] = $valval;
            }

            $nvpstr = substr($nvpstr, $valuepos+1, strlen($nvpstr) );
        }

        return array_merge($nvpArray, $paymentRequests);
    }
private function deformatNVP ( $ nvpstr ) { $ intial = 0 ; $ nvpArray = array ( ) ; $ paymentRequests = array ( ) ; while ( strlen ( $ nvpstr ) ) { //postion of Key $ keypos = strpos ( $ nvpstr , '=' ) ; //position of value $ valuepos = strpos ( $ nvpstr , '&' ) ? strpos ( $ nvpstr , '&' ) : strlen ( $ nvpstr ) ; /*getting the Key and Value values and storing in a Associative Array*/ $ keyval = urldecode ( substr ( $ nvpstr , $ intial , $ keypos ) ) ; $ valval = urldecode ( substr ( $ nvpstr , $ keypos + 1 , $ valuepos - $ keypos - 1 ) ) ; //decoding the response $ matches = array ( ) ; if ( preg_match ( "/^(L_PAYMENTREQUEST|PAYMENTREQUEST|L_PAYMENTINFO|PAYMENTINFO)_([0-9])_/" , $ keyval , $ matches ) ) { $ idx = $ matches [ 2 ] ; $ newParentKey = str_replace ( "L_" , "" , $ matches [ 1 ] ) ; if ( ! isset ( $ nvpArray [ $ newParentKey ] ) ) { $ nvpArray [ $ newParentKey ] = array ( ) ; $ nvpArray [ $ newParentKey ] [ $ idx ] = array ( ) ; } //preserve L_ to indicate multiple values $ keyval = str_replace ( "{$newParentKey}_{$idx}_" , "" , $ keyval ) ; $ targetArray = & $ nvpArray [ $ newParentKey ] [ $ idx ] ; } else { $ targetArray = & $ nvpArray ; } if ( false !== strpos ( $ keyval , "L_" ) ) { list ( $ subNum , $ subParentKey , $ subKey ) = $ this -> extractKeyValues ( $ keyval ) ; if ( ! isset ( $ targetArray [ $ subParentKey ] ) ) { $ targetArray [ $ subParentKey ] = array ( ) ; $ targetArray [ $ subParentKey ] [ $ subNum ] = array ( ) ; } $ targetArray [ $ subParentKey ] [ $ subNum ] [ $ subKey ] = $ valval ; } else { $ targetArray [ $ keyval ] = $ valval ; } $ nvpstr = substr ( $ nvpstr , $ valuepos + 1 , strlen ( $ nvpstr ) ) ; } return array_merge ( $ nvpArray , $ paymentRequests ) ; }
Parse the return string from Paypal into an Array.

@param $nvpstr
@return array
Parse the return string from Paypal into an Array .