2

I am trying to pass an array from php to python, and for some reason when I load the php page I am having trouble so I would much appreciate it if people had suggestions for me to either try a different approach or if people spot a simple error I am missing here because I have been trying to do this for hours now!

Thanks!

PHP:

<?PHP
$data = array(1,2,3,4);
$result = sell_exec('python code.py ' . escapeshellarg(json_encode($data)));
$resultData = json_decode($result, true);
var_dump($resultData);
?>

Python:

import sys
import json
def jsontoarray(json_data):
    data = json.loads(json_data)
    print(json.dumps(data))
jsontoarray(sys.argv[1])

0 Answers0