1

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])
3
  • 3
    What trouble are you having? Please describe the desired behavior and how your code is failing. Commented Jul 24, 2016 at 0:51
  • 2
    Your example has sell_exec instead of shell_exec. Commented Jul 24, 2016 at 0:55
  • @hcoat woops! That fixed it! You are a lifesaver and are like my favorite person right now! Thank you so much!! Commented Jul 24, 2016 at 1:26

1 Answer 1

0

your php code says sell_exec it should be shell_exec maybe that the problem

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.