如何从php curl访问结果

Sorry for the basic question, but I'm new to PHP.

I am using curl in php to access a record from a database. Everything works fine, in the end I am creating a variable called 'result'. My question is how can I access the xcoord and ycoord values that are within the result variable?

my curl:

  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
  curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  $result = curl_exec($ch);
  curl_close($ch);

the result of echo $result; :

{"time":0.041,"total_rows":1,"rows":[{"name":" test ","xcoord":" 13.307580499999972 ","ycoord":" 52.4212494"}]} 

Thanks for the help in advance

Looks like it's JSON

$decoded = json_decode($result);

echo $decoded->time;
echo $decoded->total_rows;
foreach($decoded->rows as $row) {
   echo $row->name;
   //so on
}