<?php
// aqui, esto es como hacerelo, para un array
function post($endpoint, $array = [], $headers = []) {
$curl = curl_init();
if (!is_resource($curl)) {
throw new \Exception();
}
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_URL, $endpoint);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $array);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
return curl_exec($curl);
}
echo post("http://localhost/test.php", [
1,2,3