Get and separate data that is not in the array

0

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
}
    
asked by anonymous 31.10.2017 / 11:37

1 answer

0
(...)
for ($i = 1; $i <= 6; $i++) {
  if(in_array($i, $menu)){
    echo 'ID '.$i.' existe no Array.<br>';

    if($menu->id >= 1 && $menu->id <= 6){
      //Descarrega o código aqui! =D
    }
  }
}

(..)

    
31.10.2017 / 11:44