-2
How do I turn this array:
$rs =
Array
(
[0] => Array
(
[DESCRICAO] => cadastrar
)
[1] => Array
(
[DESCRICAO] => editar
)
[2] => Array
(
[DESCRICAO] => deletar
)
)
in
array(cadastrar,editar,deletar)
I’m trying to do:
$permissao = 'editar';
if(in_array($permissao ,$rs)){
$permissao = true;
}else {
$permissao = false;
}
What did you try to do? What did you get? What do you know about PHP?
– Woss
This is the return of the database permissions. I need in the programming to check if the user has certain permission, for this I use in_array. Regarding PHP I am beginner.
– Francisco Alberto Coelho
Right, but have you tried the conversion you want? What was the result obtained? Error? Could you [Dit] the question and add your attempt?
– Woss
I tried to do yes. I changed in fetchAll PDO (PDO::FETCH_ASSOC) to fetchAll(PDO::FETCH_OBJ) by adding Return $rs ->DESCRICAO.
– Francisco Alberto Coelho
Place in the question the code you tried to do and describe what happened, please.
– Woss
I tried too, playing the variable in the foreach catching only the value, and nothing tbm.
– Francisco Alberto Coelho
That array
$rs
comes from the bank? uses PDO to retrieve the information?– rray
It really was duplicate. The array_map solved it. Thank you Anderson Calors Woss
– Francisco Alberto Coelho