0

Working a bit with PayPal and stumbled on the NVP response. I´m used to working with JSON and XML as a response format. But have never worked with the NVP "simplified" format. Why aren´t they and others using JSON/XML instead of NVP?

A list can look like this SomeList.Item(0).name

Is there a good way to work with NVP in PHP?

Hope somebody can explain the pros with NVP over JSON and XML and a way to work with NVP in PHP. Like how to iterate through a list.

Juw
  • 2,059
  • 4
  • 18
  • 23

2 Answers2

2

you can use PHP's parse_str() function. It parses a string like

user=test&password=123

into a PHP array in this form:

Array
(
    [user] => test
    [password] => 123
)
FLXN
  • 401
  • 3
  • 10
  • Please note that - starting from PHP 5.3.9 - the number of variables parsed by parse_str is subject to the `max_input_vars` configuration option ( [Manual](http://php.net/manual/en/info.configuration.php#ini.max-input-vars) ) with a default of 1000. Parsing of large TransactionSearch results are very likely to fail. – tillz May 09 '15 at 12:03
1

You are probably looking for the function parse_str

Here is another example I found.

Parse Paypal NVP in PHP

Community
  • 1
  • 1
Lance Badger
  • 791
  • 8
  • 13