How To Send 2d Array Through Php Curl
I'm working with a a distributed system where a php app sends a post request to a python app. My code is pretty straight forward: $ch = curl_init(); curl_setopt($ch,CURLOPT_URL
Solution 1:
php
// 2d array$arr = array(array(1,2,3),array(4,5,6),array(7,8,9));
// 2d array into json$json = json_encode($arr) // [[1,2,3],[4,5,6],[7,8,9]]
send($json)
python
import json
r = request.body # receives request from php
json = json.loads(r)
print json[0] # [1,2,3]
Post a Comment for "How To Send 2d Array Through Php Curl"