I use php curl to retrieve json data from http
, and then I use foreach array to display all the data
, but when I encounter a problem, how to break it down?
what kind of data does the counterparty need to give me?
for example, he has a total of 30 yuan
I want to do 10 times a week.
charge
$data = array(
"xxx" => "xxx"
);
$data_string = json_encode($data);
$ch = curl_init($api);
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",
"Content-Length: " . strlen($data_string))
);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
$result = curl_exec($ch);
curl_close($ch);
$data = json_decode($result);
suppose that I use foreach to print out all the data
how to make a score?
foreach ($data->orders as $order) {
}