Reputation: 137
I am really struggling with arrays in general but I can't seem to do anything with this: https://www.easycron.com/document/list
I want to be able to access each "field". For example the [cron_job_name] for [2]. So in that example the result I'd be looking for is "Send newsletters".
I have been messing around all night long but I think the thing I am not getting past is that it has the [status] => success [cron_jobs] => Array at the top.
So far the code I have is this:
$json = file_get_contents("https://www.easycron.com/rest/list?token=[MY KEY]&sortby=cronId&order=desc");
$myArray = json_decode($json,true);
echo "<pre>";
print_r($myArray);
echo "</pre>";
All this really does though is gets me a copy of what is on that page.
Upvotes: 0
Views: 55
Reputation: 328
if you are able to print_r the array response, then you can cycle
if($myArray['status'] ==='success') {
$crons = $myArray['cron_jobs'];
foreach($crons as $cron){
if($cron['cron_job_name'] == 'Send newsletters') {
// Do your proccessing
break;
}
}
}
Upvotes: 1