How to check if a deep array value is present
<p>I want to quickly identify if a key is present in an array, to avoid throwing an error.</p>

<p>For example, I might have an array like this</p>

<pre><code>$arr['f']['b']['g'] = array( 'a', 'b', 'c', ) ;
</code></pre>

<p>Or the array might not have any variables in $arr['f']['b'] at all:</p>

<pre><code>$arr['f']['x'] = array() ;
</code></pre>

<p>How can I avoid repetition in a test when referencing the (perhaps) contents of $arr['f']['b']['g']?</p>

<pre><code>if ( isset( $arr['f'] ) &amp;&amp;
     isset( $arr['f']['b'] ) &amp;&amp;
     isset( $arr['f']['b']['g'] ) /* ... yawn */ ) {
  /* blah */
}
</code></pre>

<p>There must be a terser way to identify whether a given array value I'm referencing exists? It seems far too verbose to have to test for the presence of both the value I seek, and all its ancestry as well. In some circumstances that makes sense, yes, but not all.</p>

<p>By example: it might represent, say, user->session->cart, where I want a way to quickly check whether the <em>cart</em> has entries, without having to include a check each for whether the <em>user</em> exists, then whether the <em>session</em> exists, then whether the <em>cart</em> exists, then ...</p>

<p>Edit: I'm not looking for "does an array value with a key name of 'g' exist", as "does an array value with an ancestry of f => b => g exist". </p>
