0
I know that using in_array
, i check if the value exists in the array.
I need to know if the id
, contains numbers from 1 to 6.
If any number between 1 and 6 exists, displays the message, ID existe no array
, otherwise I need to separate and store in variables the IDs
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
}
Pretty confusing your code. The value of
$dados
is a array of objects and you wonder if in any of these objects there is aid
between 1 and 6? If so, there is a much simpler way to do this.– Woss
Besides knowing if there is an ID between 1 and 6 in the array, I want to get the ID that is not in the array. Example:
1, 2 e 3 estão no array e 4,5 e 6 não estão.
– Wagner Fillio