0

After executing CURL I am getting the $result variable value as:

 {
    "ErrorCode": "000",
    "ErrorMessage": "Success",
    "JobId": "6878b812-766d-48a2-9dae-2b0edf2d84d4",
    "MessageData": [{
        "Number": "919730842844",
        "MessageParts": [{
            "MsgId": "919730842844-64a40d7611f94c03bea1045fdfa9bac5",
            "PartId": 1,
            "Text": "\u0027messagecontentsmstest\u0027"
        }]
    }]
  }

Now i need to check for the ErrorCode == 000, so how can I get the value of individually ErrorCode?

Santosh Ram Kunjir
  • 1,074
  • 1
  • 12
  • 23
N.R
  • 191
  • 1
  • 13
  • You need to properly format your question, by putting code and the like in code tags. A question should also show: A minimum working example to reproduce the problem and what you were trying to do! This question is gonna get closed otherwise – LeonH Aug 25 '15 at 07:55

1 Answers1

1

This response received is like JSON.

So I thought to decode it as an json_decode:

$chk = json_decode($result); echo $chk->ErrorCode;

or we can even try in another way like,

$array = json_decode($result, true); echo $array['ErrorCode'];

N.R
  • 191
  • 1
  • 13