I have received a response from server as a string, which I converted as array, but still I am not able to make out, how I can access values from this array like
myarrray['txn_status'];
as also from the string clnt_rqst_meta
array(13) {
[0]=>
string(15) "txn_status=0399"
[1]=>
string(15) "txn_msg=failure"
[2]=>
string(55) "txn_err_msg=Transaction Cancelled : ERROR CODE TPPGE161"
[3]=>
string(17) "clnt_txn_ref=9178"
[4]=>
string(15) "tpsl_bank_cd=NA"
[5]=>
string(19) "tpsl_txn_id=T245107"
[6]=>
string(14) "txn_amt=121.00"
[7]=>
string(47) "clnt_rqst_meta={mob:9937253528}{custname:pawan}"
[8]=>
string(16) "tpsl_txn_time=NA"
[9]=>
string(15) "tpsl_rfnd_id=NA"
[10]=>
string(10) "bal_amt=NA"
[11]=>
string(47) "rqst_token=cd3f6f55-5990-4c3b-bb12-238eede827a0"
[12]=>
string(45) "hash=3cf25909ec73865d3200bc267119d3fcc21df463"
}
I know that the same can be achieved using regex/preg_match, but I am sure there must be some straight forward way to achieve it.
update: the actual string received from response is like this:
string(342) "txn_status=0399|txn_msg=failure|txn_err_msg=Transaction Cancelled : ERROR CODE TPPGE161|clnt_txn_ref=9178|tpsl_bank_cd=NA|tpsl_txn_id=T245107|txn_amt=121.00|clnt_rqst_meta={mob:9937253528}{custname:pawan}|tpsl_txn_time=NA|tpsl_rfnd_id=NA|bal_amt=NA|rqst_token=cd3f6f55-5990-4c3b-bb12-238eede827a0|hash=3cf25909ec73865d3200bc267119d3fcc21df463"
so I used $response =explode("|",$response_str);