I have a lot of code, but I do not think it's one of the best, because I'm a beginner in programming. The values are coming in duplicates, I'd like to know if the way I'm performing the code is correct and how to make the values not duplicate:
// Percorrendo os Jobs
foreach ( $asana->getData() as $tasks )
{
// Pegando ID & Incrementado a Conta
$ids = $tasks->id;
$exibir = true;
$jobs++;
// Pegando detalhes dos Jobs
$getTask = $asana->getTask($ids, array('opt_fields' => 'name,completed,assignee_status,created_at,due_on'));
$getTask = json_decode($getTask);
// Percorrendo os dados
foreach($getTask as $item)
{
// Pegando os Jobs Completos & Incompletos
if ( $item->completed ) { $jobs_completos ++; }
$jobs_incompletos = $jobs-$jobs_completos;
// Pegando as datas
if ( $item->due_on )
{
$datas[] = $item->due_on;
}
$conta_data = count($datas, COUNT_RECURSIVE);
$conta_sem_data = $jobs-$conta_data;
}
// Jobs do Mês
foreach ( $datas as $data )
{
// Recuperando as datas
$data = date('d/m/Y', strtotime($data));
$data = explode("/", $data);
$hoje_dia = date('d'); // Dia
$hoje_mes = date('m'); // Mês
$hoje_ano = date('Y'); // Ano
// Pegando os Jobs do Mês
$jobs_mes = 0;
if ( $data[1] == $hoje_mes )
{
echo $data[0]." / ".$data[1]." / ".$data[2]."<br />";
$jobs_mes++;
}
}
}
I do not need this much of " Foreach's " how can I "improve" this code?