I have an array of data comes from $_POST and I want to send them by curl to another page.
curl_setopt($s,CURLOPT_POST,true);
curl_setopt($s,CURLOPT_POSTFIELDS,$this->_postFields);
$this->_postFields must be an string like a=2&b=t right?
so if I want to send array of data with curl to another page I must turn array to query string right?
How should I do it with PHP?
♦I tried serialize() and unserialize() but thier format is not same as query string right?
so what should I do? (I need something like .serialize() in jQuery that work on array not FORM)
♦ And the destination path is not under my control and the $_POST in the destination should be as $_POST not as its base64 encoded so I can't use such codes.
$array = array(1,2,3);
$encoded = json_encode($array);
$decoded = json_decode($encoded);
print_r($decoded);
Any Ideas?
thanks in advance.
http_build_query()might be helpful: PHP Function To Build Query String From Array