The json format.
{
"message-count":"1",
"messages":[
{
"status":"returnCode",
"error-text":"error-message"
}
]
}
In php, I successfully get "status" value with $response->messages[0]->status
But when I wanted to access "error-text" properties, the code $response->messages[0]->error-text gives me error.
How to access object properties with hyphen?
here is the way!
$object->{"message-count"};
$response->messages[0]->{'error-text'};
hope this helps
any string (bytes sequence) can be used as a class field
$object->{"123"} = 10; // numbers
$object->{"{a}"} = 10; // special characters
$object->{"òòèè"} = 10; // non ascii characters
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With