I know that using in_array
, I check if the value exists in the array.
I need to know if id
contains numbers from 1 to 6.
If any number between 1 and 6 exists, it displays the message, ID existe no array
, otherwise I need to separate and store the IDs
variables that were not found.
public function atualizar_menu($dados)
{
$array = (array)$dados;
foreach ($dados as $mnu){
$menu = array(
'id' => $mnu->id,
'permissao_id' => $mnu->permissao_id,
'padrao' => $mnu->padrao,
);
print_r($menu);
for ($i = 1; $i <= 6; $i++) {
if(in_array($i, $menu))
{
echo 'ID '.$i.' existe no Array.<br>';
}
}
}//Fim do foreach
}