This question already has answers here:
Answer
Solution:
Your JSON is a little bit complex. I have a solution below that access text
property from the nested JSON.
$array = json_decode( $json, true );
echo ($array['rows'][0] ["elements"][0]['distance']['text']);
Source