According to this mine question Python find value in array by filter
This is what I have done
data = {}
for result in results:
if 'stackoverflow.com' in result['serp_url']:
data['url'] = result['serp_url']
data['rank'] = result['serp_rank']
data['query'] = result['query']
print(data)
exit
This is PHP code
$test = shell_exec("python3 py.py");
var_dump($test);
And this is output
/home/user/Desktop/pyphp/index.php:4:string '{'url': 'https://stackoverflow.com/', 'rank': 1, 'query': 'stackoverflow'}
{'url': 'https://www.quantcast.com/stackoverflow.com', 'rank': 36, 'query': 'stackoverflow'}
' (length=168)
When I use json_decode($test)
I'm getting null as output.
What's the best way to use as json or array output from Python in PHP?