I have an object in which there are modules in the form of an array. What I want is that when I click on Select, on the right side they can not appear repeated. It does not give me errors but it does not perform the function that I want.
Code:
public function anadirAlArray($codigo) {
$modulo=DB::consultaModulo($codigo);
array_push($this->modulosSel, $modulo);
echo '<table border="1">';
echo '</tr>';
echo '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
foreach ($this->modulosSel as $modulo){
echo '<tr>';
$cod = $modulo->getCodigo();
$nombre= $modulo->getNombre();
if (in_array($nombre,$this->modulosSel)) {
echo "Modulo existente";
}else{
echo '<td>'.$nombre." ".'<input type="submit" name="quitarModulo[' .$cod.']" value="Quitar">'."<br>";
echo '</tr>';
}
}
echo "</form>";
echo '</table>';
}