I'm brand new to php and curl. I have a php function which is retrieving data from an API utilizing curl. This is working correctly. However, the APIs data will be updating, so I will need to periodically retrieve the json-formatted data.
function call_external_api()
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, sprintf('https://my-api.com'));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
$ex = curl_exec($curl);
$data = json_decode($ex, true);
$info = curl_getinfo($curl);
return $data;
}
So basically if I want to call this php function every 10 seconds, how would I go about doing so?