I have two arrays and I need to verify what is different between them, like:
Something exists in array A but not in B,
One argument is diferent in array A when comparing to B...
$temp = import_temp::select('cod_disciplina', 'cod_turma', 'hr_inicio', 'hr_fim', 'dia_semana')->get();
$turmas;
foreach($temp as $t)
{
$turmas = Horario::select('cod_disciplina', 'cod_turma', 'hr_inicio', 'hr_fim', 'dia_semana')
->whereIn('cod_disciplina', $temp->lists('cod_disciplina'))
->whereIn('cod_turma', $temp->lists('cod_turma'))
->where('ano_semestre', $ano_semestre)->get();
}
When I do:
print_r($turmas->toArray());
print_r($temp->toArray());
How may I compare these keys and identify when something changed
is new
or is missing
.
Tried working with array_diff_assoc
but I get the following error:
Array to string conversion
array_diff_assoc($temp->toArray(), $turmas->toArray());
Also tried This that I found in another answer in a similar question but didn't work.