php array_search returning 0 for the first element?

I think it will be better to use in_array() in this case

$restaurant = array('/restaurant_pos/', '/bar_nightclub_pos/')
$current_page = $_SERVER['REQUEST_URI'];

if (in_array($current_page, $restaurant)) {
    echo "KEEP ME";
}

http://php.net/manual/en/function.in-array.php


I have used is_numeric function to achieve the same.

if(is_numeric(array_search($entry, $array))){
            //if true, this block will be executed
 }

if (array_search($current_page, $restaurant) !== FALSE ) {
    echo "KEEP ME";
}

Manual link: http://php.net/manual/en/function.array-search.php

Tags:

Php

Arrays