title: PHP Notice: Undefined index when looping array
body: <p>I'm looping a two-dimensional array like this:</p>
  
  <pre><code>if (!empty($aka)) {
      foreach ($aka as $ak) {
          if($ak["lang"]=="es") {
              $sptitle=$ak["title"];
          }
      }
  }
  </code></pre>
  
  <p>Pretty simple. If the array ($aka) is not empty I loop trough it and when it finds that the "lang" index is equal to "es" I just save the "title" value for that index in $sptitle.</p>
  
  <p>The problem is that the array ($aka) contains a lot of information and sometimes there is no "lang" index... and I get this error: Notice: Undefined index: lang.</p>
  
  <p>How can I fix this???</p>
  
  <p>This is a extract of the array to help you understand. Notice that [1] doesn't have a [lang] index but [2] does have:</p>
  
  <pre><code>[1] =&gt; Array
      (
          [title] =&gt; "The Lord of the Rings: The Motion Picture"
          [year] =&gt; ""
          [country] =&gt; "USA"
          [comment] =&gt; "promotional title"
      )
  
  [2] =&gt; Array
      (
          [title] =&gt; "Señor de los anillos: La comunidad del anillo, El"
          [year] =&gt; ""
          [country] =&gt; "Argentina"
          [comment] =&gt; "Chile, Mexico, Peru, Spain"
          [lang] =&gt; "es"
      )
  </code></pre>
  
  <p>Thanks!</p>