附加的代码返回"注意:数组到字符串转换...".只是我的数组被作为包含"Array"字符的字符串处理到远程服务器.其余的变量都很好.
如何在$anarray没有这个问题的情况下传递我的数组?
<?php
$data = array(
'anarray' => $anarray,
'var1' => $var1,
'var2' => $var2
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "MY_URL");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_exec($ch);
?>
Run Code Online (Sandbox Code Playgroud)
Joh*_*nde 30
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
// The values of variables will be shown but since we don't have them this is what we get
Run Code Online (Sandbox Code Playgroud)
然后,您可以使用$_POST超全局正常访问它
Eri*_*era 15
实现目标的最佳方法是使用http_build_query().