Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Newbie question

13 views
Skip to first unread message

otaksoft...@gmail.com

unread,
Nov 27, 2016, 7:43:22 PM11/27/16
to
$ret = json_decode(substr($result, 3), true);
var_dump($ret);

yields:

array(4) {
["customerPaymentProfileIdList"]=>
array(0) {
}
["customerShippingAddressIdList"]=>
array(0) {
}
["validationDirectResponseList"]=>
array(0) {
}
["messages"]=>
array(2) {
["resultCode"]=>
string(5) "Error"
["message"]=>
array(1) {
[0]=>
array(2) {
["code"]=>
string(6) "E00039"
["text"]=>
string(53) "A duplicate record already exists."
}
}
}
}

How can I extract the code E00039 from $ret?

Thanks fo any help!

Jerry Stuckle

unread,
Nov 27, 2016, 9:26:25 PM11/27/16
to
Look at your variable.

The variable name is $ret.

It has 4 named array members:
"customerPaymentProfileIdList"
"customerShippingAddressIdList"
"validationDirectResponseList"
"messages"

From that, you have 2 named array members:
"resultCode"
"message"

Again, it is the latter of the two you need.

That has one array member with an index of 0.

And this has 2 named array members:
"code"
"text"

From which you want the first.

So the entire access would be:
$ret["messages"]["message"][0]["code"]

--
==================
Remove the "x" from my email address
Jerry Stuckle
jstu...@attglobal.net
==================

otaksoft...@gmail.com

unread,
Nov 27, 2016, 10:29:59 PM11/27/16
to
thanks!
0 new messages