title: What is the best way to access unknown array elements without generating PHP notice?
body: <p>If I have this array,</p>
  
  <pre><code>ini_set('display_errors', true);
  error_reporting(E_ALL);
  
  $arr = array(
    'id' =&gt; 1234,
    'name' =&gt; 'Jack',
    'email' =&gt; 'jack@example.com',
    'city' =&gt; array(
      'id' =&gt; 55,
      'name' =&gt; 'Los Angeles',
      'country' =&gt; array(
        'id' =&gt; 77,
        'name' =&gt; 'USA',
       ),
    ),
  );
  </code></pre>
  
  <p>I can get the country name with</p>
  
  <pre><code>$name = $arr['city']['country']['name'];
  </code></pre>
  
  <p>But if the country array doesn't exist, PHP will generate warning:</p>
  
  <pre><code>Notice: Undefined index ... on line xxx
  </code></pre>
  
  <p>Sure I can do the test first:</p>
  
  <pre><code>if (isset($arr['city']['country']['name'])) {
    $name = $arr['city']['country']['name'];
  } else {
    $name = '';  // or set to default value;
  }
  </code></pre>
  
  <p>But that is inefficient. What is the best way to get <code>$arr['city']['country']['name']</code> 
  without generating PHP Notice if it doesn't exist?</p>