以逗號分開的值,用curl and json傳送給http

火爆浪子
  • 2.8k

假設欄位值

2018/04/16, 2018/04/17, 2018/04/18, 2018/04/19, 2018/04/20, 2018/04/21, 2018/04/28

當我另一面處理的時候
如何轉換成 array 並且丟json給指定的http? 利用curl

$data = array(
    "date" => $date
  );
  $data_string = json_encode($data);
  $ch = curl_init($api_signin);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
  curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
  $result = curl_exec($ch);
  curl_close($ch);

$date這邊怎麼寫才對啊?

回复
阅读 1k
1 个回答
$data = array('2018/04/16','2018/04/17','2018/04/18','2018/04/19','2018/04/20','2018/04/21','2018/04/28');
你知道吗?

宣传栏