I have this data
$result = json_decode(curl_exec($ch));
print_r($result);
// stdClass Object ( [d] => {"id":10} )
$id = ?;
How can I get a value of id?
Since $result is an object, you have to use property notation to access its components.
$id = json_decode($result->d)->id;
You need the extra json_decode because the value of $result->d is another JSON string, not an object or array.
var_dump instead of print_r, so the types of all the values would be more obvious.You would get value with following
$obj_result = json_decode($result->d);
echo $obj_result->id;
By this way you will get id value 10
$result->d is the string '{"id":10}', not an array, so you can't index it.