I'm trying to make a if
within a foreach
and the situation is as follows:
I have array
that I called $ enrollments which returns like this:
array(2) { [0]=> array(1) { ["chave"]=> string(1) "1" } [1]=> array(1) { ["chave"]=> string(1) "3" } }
And I tried this code:
foreach($matriculas as $matricula){
if(in_array($row['id_curso'],$matricula)){
echo '<a href="" class="btn btn-success disabled">Matriculado</a>';
}else{
echo 'nois';
}
}
I would like to display the information if the value of $row['id_curso']
exists in $matricula
, if it does not exist it should show a button whatever. The problem is that it displays both, ie, $row['id_curso']
exists in $matriculas
or not existing. Is there a way to fix this?