I am trying to check if an element is not in array than want to redirect page:
My code is as below:
$id = $access_data['Privilege']['id'];
if(!in_array($id,$user_access_arr))
{
$this->Session->setFlash(__('Access Denied! You are not eligible to access this.'), 'flash_custom_success');
return $this->redirect(array('controller'=>'Dashboard','action'=>'index'));
}
I am confused how to check if element is not in array.
As we can check element exist or not in array using in_array
function of PHP.
I am trying to check it using (!in_array)
but I did not got result.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…