I am trying to parse a simple response from the server and use its values.
I was able to get the required information as follows:
The actual response :
AccountID=0&Authenticated=1&ResponseCode=0&ResponseText=Success
What I need is separate values for :
- AccountID
- Authenticated
- ResponseCode
- ResponseText
My code so far :
$tempValue = explode("
", $response);
foreach($tempValue as $row => $data)
{
//get row data
$row_data = explode('&', $data);
$row_internal = explode('=', $row_data);
$info2[$row]['id'] = $row_internal[0];
$info2[$row]['name'] = $row_internal[1];
$info2[$row]['description'] = $row_internal[2];
$info[$row]['id'] = $row_data[0];
$info[$row]['name'] = $row_data[1];
$info[$row]['description'] = $row_data[2];
echo 'Account ID: ' . $info[$row]['id'] . '<br />';
echo 'Authenticated: ' . $info[$row]['name'] . '<br />';
echo 'Response Code: ' . $info[$row]['description'] . '<br />';
echo '<br></br>';
echo 'Account ID: ' . $info2[$row]['id'] . '<br />';
echo 'Authenticated: ' . $info2[$row]['name'] . '<br />';
echo 'Response Code: ' . $info2[$row]['description'] . '<br />';
}
Result for the above code :
Account ID: AccountID=0
Authenticated: Authenticated=1
Response Code: ResponseCode=0
Account ID:
Authenticated:
Response Code:
What I needed was just the values for the fields like :
Account ID: 0
Authenticated: 1
Response Code: 0