如何将数组传递到另一个页面? 我的代码有什么问题?
$r=mysql_query("select * from pay where PayID=1");
$ar=array();
while ($record=mysql_fetch_array($r))
{
array_push($ar,$record['Reserveid']);
}
var_dump($ar);
$url = 'http://--/a.php';
$client = curl_init($url);
curl_setopt($client, CURLOPT_POST,1);
$data = array(
'r' =>$ar
);
curl_setopt($client, CURLOPT_POSTFIELDS,$data);
curl_setopt ($client, CURLOPT_RETURNTRANSFER,1);
curl_setopt($client, CURLOPT_FOLLOWLOCATION, 1);
$response = curl_exec($client);
echo $response;
$r=$_POST['r'];
var_dump($r);
输出
array(3) { ...... }
-------------------------------
string(5) "Array"
答案 0 :(得分:1)
$data
应该是:
$data = http_build_query(array(
'r' => $ar
));