how to solve Notice: Undefined offset: 1? I used the following function to alter menu (hook_menu_alter)

function _term_account(){
  global $base_url;
  global $user;
  $account_id = custom_get_user_account_id();
  $tesr = explode('_', arg(3));
  if($tesr[1] == $account_id){
    return true;
 } else {
    return false;
 }
}

function custom_menu_alter(&amp;$items) {
  // Works fine.. So every user has he's own and only vocabulary return true..
  $items['admin/structure/taxonomy/%taxonomy_vocabulary_machine_name/list']['access callback'] = '_term_account';
  }


and it works fine.. but.. when i go to reports/dblog in my site.. i have over than 30 row of same error


  Notice: Undefined offset: 1 in _term_account() (line 277 of
  ../public_html/sites/all/modules/custom/custom.module).


Is there something wrong in the function?
This line of code will split arg(3) into an array of strings using _ as the delimiter.

  $tesr = explode('_', arg(3));


Assuming that in this case arg(3) is never empty, it is still possible that there are no underscores in arg(3), in which case you will have an array of 1 item.

Since arrays are zero based, this will give you something like

Array
(
    [0] =&gt; 'somestring'
)


In that case, your next piece of code

  if ($tesr[1] == $account_id) {


will throw the Undefined offset: 1 notice because there is no array element with the key 1.

If you want to safely use $tesr[1] you have to do something like

  if (isset($tesr[1]) &amp;&amp; $tesr[1] == $account_id) {


Additional unsolicited feedback:


Don't name your module 'custom'. Name it something more descriptive of its purpose. If it has many distinct purposes split it into multiple modules. It will be easier to maintain in future if you can easily tell what different modules do.
Always prefix your function names with the name of the module. _term_account() might clash with another module's function. Prefixing with your module's name helps avoid that.
You have global $base_url; and global $user; but then you never use them. 
Consider using a variable name that is more descriptive than $tesr, so you can easily tell what it means if you come back to the code in future.
Code is easier to work on if it uses consistent formatting standards. Check out Drupal's at https://www.drupal.org/docs/develop/standards