PHP cURL - 发送数组成功但不完全

时间:2011-09-13 14:10:40

标签: php curl multidimensional-array

我正在使用CURL发布到远程服务器上托管的脚本。 我正在使用这个发送一个多维数组:

 $urlserver = "myserver";
 $arraytag =      array('tags'=>$taggenerici,'tagesplosi'=>$tagesplosi,'matrice'=>$matricefin,'id' =>$identificativo);
 $postfields = http_build_query($arraytag);

 //open connection
 $ch = curl_init();

 curl_setopt($ch,CURLOPT_URL,$urlserver);
 curl_setopt($ch, CURLOPT_HEADER, 0);
 curl_setopt($ch,CURLOPT_POST,sizeof($postfields));
 curl_setopt($ch, CURLOPT_POSTFIELDS,$postfields);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER  ,1);  // RETURN THE CONTENTS OF THE CALL

 //execute request sending post
 $result = curl_exec($ch);
 echo $result;

 //close connection
 curl_close($ch);

问题在于结果:事实上,如果我尝试执行我的脚本,我会得到一个随机结果。我想查看20个X 43列的数组,但它在第10行和第28列停止。但是,如果我尝试刷新我的页面,我会得到我的完整数组。

我想说我在将数据发送到远程服务器之前尝试获取数据并且工作正常,因为我完全不需要任何切割就可以获得数组。


正在调用

脚本(减去未使用的mysql连接):

<?php

$taggenerici = $_POST['tags'];
$matrice = $_POST['matrice'];
$identificativo = $_POST['id'];
$tagesplosi = $_POST['tagesplosi'];

//Here i create the array with "a" and "?"
for($dom=0;$dom<sizeof($identificativo);$dom++) {
    for ($tag=0;$tag<sizeof($taggenerici);$tag++) {
        $matrice[$dom][$tag] = "a, ";
    }
    $tagAdd=sizeof($taggenerici)+1;
    $matrice[$dom][$tagAdd] ="?";
}

//Here i set "p".
for($dom=0;$dom<sizeof($identificativo);$dom++) {
    for ($tag=0;$tag<sizeof($taggenerici);$tag++) {
        for ($tagarray=0;$tagarray<sizeof($tagesplosi[$dom]);$tagarray++) {
            if ($taggenerici[$tag] == $tagesplosi[$dom][$tagarray]) {
                $matrice[$dom][$tag] = "p, ";
            }
        }
    }
}

//this is the $result which I call on the client. (echo $valore);
foreach ($matrice as $kappa => $vu) {
    echo "<br>";
    foreach ($vu as $kii => $valore)
        echo $valore;
    }
} 

0 个答案:

没有答案