how to print variables (separately) from a python script to a php

EDIT: i changed echo to print_r($output) and this is the result :

Array ( [0] => {"leftCoordinate": 5125, "rightCoordinate": 30} )

is there a way so that $output[0] would just be 5125 and $output[1] to be 30?


I'm trying to grab variables from a python script via php, and print it out on html.

I've been told that i could do it with JSON but i'm not really familiar with it.

for example this is my

import json

x = {
  "leftCoordinate": 5125,
  "rightCoordinate": 30

y = json.dumps(x)


and this is my php code:

json_decode(exec("C:/Users/hln/Anaconda3/envs/tensorflow1/python.exe C:/tensorflow1/models/research/object_detection/", $output));
echo $output[0];

I'm aiming for the output to just be 5125 and 30 (in separate variables, so i could print it out separately) but the output that i got is: {"leftCoordinate": 5125, "rightCoordinate": 30}