public function index($key, $val)
    {
        $db = $this->load();
        foreach ($db as $index => $row) {
            if ($row[$key] === $val) {
                return $index;
                break;
            }
        }
        return -1;
    }
public function index($key, $val)
    {
        $db = $this->load();
        foreach ($db as $index => $row) {
            if ($row[$key] === $val) {
                return $index;
                break;
            }
        }
        return -1;
    }
public function index ( $ key , $ val ) { $ db = $ this -> load ( ) ; foreach ( $ db as $ index => $ row ) { if ( $ row [ $ key ] === $ val ) { return $ index ; break ; } } return - 1 ; }
Returns the index of a row where the given key matches value.

@param string $key   the key to search for
@param string $val   the value to check for
@return integer      the index of the row found, or -1 if no row matched
Returns the index of a row where the given key matches value .