Notice: Undefined offset: 1 error I get this Notice:


  Notice: Undefined offset: 1 in
  custom_context_section_condition->_get_url_section() (line 110 of
  modules/custom/custom_context/plugins/custom_context_section_condition.inc).


  **
  * Get section by url
  */
  function _get_url_section() {
    // get the correct URL
    $path = $_GET['q'];
    if (arg(0) == 'node' &amp;&amp; is_numeric(arg(1))) {
      $path = drupal_get_path_alias($_GET['q']);
    }
    $path = explode('/', $path);

    // Remove reserved part from path when defined as constant (see custom_context.module)
    if (in_array(arg(0), unserialize(URL_PATH_PART))) {
      array_shift($path);
    }
    // Remove reserved string from path when defined as constant (see custom_context.module)
    else if ($new_path = _custom_context_strpos_replace_arr($_GET['q'], unserialize(URL_PATH_STRING))) {
      $path = explode('/', $new_path);
    }

    // Get section by path
    $value = str_replace('-', ' ', $path[1]);
    $terms = taxonomy_get_term_by_name($value);

    // make sure we are getting the right section under the correct city
    // check if city context exist
    $city = NULL;
    $contexts = context_active_contexts();
    if ($contexts = context_active_contexts()) {
      foreach ($contexts as $key =&gt; $context) {
        if ($key == 'city') {
          $city = $context-&gt;conditions['custom_city']['city']['term'];
          break;
        }
      }
    }
    else {
      $city_context = new custom_context_city_condition(this, array());
      $cities = $city_context-&gt;_get_city($node);
      $city = array_shift($cities);
    }

    // check parent tid here
    foreach ($terms as $key =&gt; $term) {
      $parents = taxonomy_get_parents($term-&gt;tid);
      $parent = array_shift($parents);
      if ($city-&gt;tid != $parent-&gt;tid) {
        unset($terms[$key]);
      }
    }
    return $terms;
  }


This part:

if ($city-&gt;tid != $parent-&gt;tid) {
  unset($terms[$key]);
}


Also says: Notice: Trying to get property of non-object

Any idea whats wrong in my code?
In the code above $parent is an array so $parent-&gt;tid is illegal. I am not sure what you are trying to find in the $parent but you should also note that the parent array has numeric indicies. So you probably have to do it this wat $parent[45] or $parent[$city-&gt;tid] depending on your requirement