Issue
I'm new in for SOAP API and i got response from web services . But i'm not able to convert it in array to get the keys.
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:setTransactionResponse xmlns:ns2="http://soap.api.controller.web.payjar.com/">
<return>
<merchantReference>mercRef_1395758213</merchantReference>
<payUReference>17613281409117</payUReference>
<successful>true</successful>
</return>
</ns2:setTransactionResponse>
</soap:Body>
</soap:Envelope>
Solution
try the following to xml response to an array
$xml = $response;
$xml = preg_replace("/(<\/?)(\w+):([^>]*>)/", "$1$2$3", $xml);
$xml = simplexml_load_string($xml);
$json = json_encode($xml);
$responseArray = json_decode($json,true);
echo "<pre>";print_r($responseArray);
Output
Array
(
[soapBody] => Array
(
[ns2setTransactionResponse] => Array
(
[return] => Array
(
[merchantReference] => mercRef_1395758213
[payUReference] => 17613281409117
[successful] => true
)
)
)
)
Answered By - Forge Web Design