find word within strings array

1

I'm using the following code:

foreach ($lista_grupos as $key => $value) {
    if(strpos($lista_grupos[$key],'Tecnologia_da_Informacao')===true){
        $admin = true;
    }else{
        $admin = false;
    }
}

But it always returns false, can not find the string I want. What am I doing wrong? Follow array:

(array =>
    [21] => CN=Tecnologia_da_Informacao,OU=Tecnologia_da_Informacao,OU=03-Operadora,DC=asdt,DC=com,DC=br
    [22] => CN=asdasd,OU=02-Grupos,DC=uniiaca,DC=com,DC=br
    [23] => CN=asdasd,OU=02-Grupos,DC=jçasdia,DC=com,DC=br
)
    
asked by anonymous 10.11.2015 / 01:21

1 answer

1

I have not programmed in php for a long time, but from what I read in the documentation , the% with% returns an integer and you compare with boolean ali. For the documentation, use something like this:

if ($pos !== false) {
    $admin = true;
    return ...;
}

The strpos() compares the result plus the type. The === can return false but will never return true but an integer from the first occurrence of your string ( Operators PHP ).

    
10.11.2015 / 01:37