The array search always returns false, even if it is not

advertisements

Ok it's late night and I'm working non-stop from too many hours so here's why I don't manage to understand what's the problem here. I have an array:

Array
(
    [bob] =>
    [mike-2] =>
    [tara] => example.com
)

I want to get the key searching for value so I'm using array_search:

// With an if statement...
if(in_array($_SERVER['SERVER_NAME'], $array)!==false)
{
    // something
}

// ... and also directly with this
$key = array_search($_SERVER['SERVER_NAME'], $array);
echo $key;

Result? Always false! There's no way for me to get tara when I'm looking for example.com. What the heck am I missing? I even tried replacing $_SERVER['SERVER_NAME'] directly with "example.com" but of course it still doesn't work.

Edit: it was a typo error... damn. I wasted 2 hours for this.


Stop working. This is an actual answer. Just stop. Whenever it comes to you wasting two hours on a typo you're doing nobody any good, especially yourself.

Rest, you're not getting anywhere like this.