I'm new to programming so maybe its something simple but when i run the script it gives the output that the return $response is not defined but it is defined in the array.
already tried moving the return statement but it doesn't help
this it just a piece of the code but this is the part that gives problems
function request($opt, $data) {
$request = curl_init();
foreach ($data as $status) {
$data_string = json_encode($status);
echo "Json: " . $data_string . PHP_EOL;
$headers = array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string)
);
$url = ENDPOINT . $opt['object'];
curl_setopt($request, CURLOPT_URL, $url);
curl_setopt($request, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($request, CURLOPT_POST, TRUE);
curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($request, CURLOPT_USERPWD, USERNAME . ":" . PASSWORD);
$response = curl_exec($request);
if ($response == FALSE) {
die('<p>Curl failed: ' . curl_error($request) . '</p>');
}
}
return $response;
}