我在表单中有复选框,我正在发布到 php 表单处理器。我的表单处理器向 Web 服务发送一个获取请求。请求需要类似于此的每个复选框 ?services=Chin&services=Neck&services=Back&location=5
没有键值,但使用我的 php 代码,它在每次服务后输出一个 [] 。
//build query string
$fields = array('services' => $services,
'location' => $location,
'firstname' => $firstname,
'lastname' => $lastname,
'email' => $email,
'emailconfirm' => $email,
'phone' => $telephone,
'comments' => $message);
$url = "fakewebaddress?" . http_build_query($fields, '', "&");
//send email if all is ok
if($formok){
$curl_handle = curl_init($url);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true);
$results = curl_exec($curl_handle);
curl_close($curl_handle);
}
我的 html 框看起来像这样
<input type="checkbox" name="services[]" value="Leg" />
<input type="checkbox" name="services[]" value="Chest" />
<input type="checkbox" name="services[]" value="Neck" />
<input type="checkbox" name="services[]" value="Back" />
如何修复它以获得我需要的输出?