i get object from json like this
{"valid":"yes","date":"2017-01-04","data-val":{"current":25}}
i want to get current value i create a var include name current
$johndoe = 'current';
but i fail to call it like this :
$currentjohn = $data['data-val'][$johndoe];
fail
$currentjohn = $data['data-val']['.$johndoe.'];
also fail
$currentjohn = $data['data-val']->$johndoe;
fail too
how to do it right way or how to get 'current' if i didn't know that key name is current
thank you for helping