<?php
$xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><paymentresponse><merchant><merchantid>1000001</merchantid><accountid>2000034</accountid></merchant><transaction><merchantref>yAq3ueCIDG1u3Q9Y2Tfs</merchantref><amount>1000</amount><currency>USD</currency><transactiontype>ECOMMERCE</transactiontype></transaction><status><code>SUCCESS</code><message>Operation successful</message><timestamp>2012-07-24T13:48:05+01:00</timestamp></status></paymentresponse>';
$data = (array) simplexml_load_string($xml);
var_dump($data);
var_dump(json_decode(json_encode($data),1));
- Output for 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
- array(3) {
["merchant"]=>
object(SimpleXMLElement)#2 (2) {
["merchantid"]=>
string(7) "1000001"
["accountid"]=>
string(7) "2000034"
}
["transaction"]=>
object(SimpleXMLElement)#3 (4) {
["merchantref"]=>
string(20) "yAq3ueCIDG1u3Q9Y2Tfs"
["amount"]=>
string(4) "1000"
["currency"]=>
string(3) "USD"
["transactiontype"]=>
string(9) "ECOMMERCE"
}
["status"]=>
object(SimpleXMLElement)#4 (3) {
["code"]=>
string(7) "SUCCESS"
["message"]=>
string(20) "Operation successful"
["timestamp"]=>
string(25) "2012-07-24T13:48:05+01:00"
}
}
array(3) {
["merchant"]=>
array(2) {
["merchantid"]=>
string(7) "1000001"
["accountid"]=>
string(7) "2000034"
}
["transaction"]=>
array(4) {
["merchantref"]=>
string(20) "yAq3ueCIDG1u3Q9Y2Tfs"
["amount"]=>
string(4) "1000"
["currency"]=>
string(3) "USD"
["transactiontype"]=>
string(9) "ECOMMERCE"
}
["status"]=>
array(3) {
["code"]=>
string(7) "SUCCESS"
["message"]=>
string(20) "Operation successful"
["timestamp"]=>
string(25) "2012-07-24T13:48:05+01:00"
}
}
- Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6
- array(3) {
["merchant"]=>
object(SimpleXMLElement)#2 (2) {
["merchantid"]=>
string(7) "1000001"
["accountid"]=>
string(7) "2000034"
}
["transaction"]=>
object(SimpleXMLElement)#3 (4) {
["merchantref"]=>
string(20) "yAq3ueCIDG1u3Q9Y2Tfs"
["amount"]=>
string(4) "1000"
["currency"]=>
string(3) "USD"
["transactiontype"]=>
string(9) "ECOMMERCE"
}
["status"]=>
object(SimpleXMLElement)#4 (3) {
["code"]=>
string(7) "SUCCESS"
["message"]=>
string(20) "Operation successful"
["timestamp"]=>
string(25) "2012-07-24T13:48:05+01:00"
}
}
Fatal error: Call to undefined function json_decode() in /in/p4NPJ on line 7
Process exited with code 255. - Output for 4.4.5 - 4.4.9
- Fatal error: Call to undefined function: simplexml_load_string() in /in/p4NPJ on line 5
Process exited with code 255. - Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.4
- Fatal error: Call to undefined function: simplexml_load_string() in /in/p4NPJ on line 5
Process exited with code 255. - Output for 4.3.0 - 4.3.1
- Fatal error: Call to undefined function: simplexml_load_string() in /in/p4NPJ on line 5
preferences:
275.89 ms | 401 KiB | 462 Q