I have the following PHP code:
<?php
exec("./mycode.py", $out)
var_dump($out)
?>
It produces the following output:
array(2) { [0]=> string(28) "{"ky2": "bar", "ky1": "foo"}" [1]=> string(30) "{"ky2": "bar2", "ky1": "foo2"}" }
How can I iterate the output above and print the result?
Entry 0
ky1 - foo
ky2 - bar
Entry 1
ky1 - foo2
ky2 - bar2
They Python code (mycode.py
) is this:
#!/usr/bin/env python
import json
dict1 = {'ky1':'foo', 'ky2':'bar'}
dict2 = {'ky1':'foo2', 'ky2':'bar2'}
print json.dumps(dict1)
print json.dumps(dict2)
It prints this:
{"ky2": "bar", "ky1": "foo"}
{"ky2": "bar2", "ky1": "foo2"}