PHP getting data from array
<p>The following array has multiple data arrays. Some of the data arrays have field <code>message</code>, while others don't have. </p>

<p>I want to get the <code>message</code> and the <code>created_time</code> field from the arrays which have those fields. </p>

<p>I can get the data without the loop, for example:</p>

<pre><code>$msg = $json['posts']['data'][0]['message'];
</code></pre>

<p>but how can I use the loop and get the message fields from all arrays which have that field.</p>

<pre><code>Array
(
    [id] =&gt; 1234
    [posts] =&gt; Array
        (
            [data] =&gt; Array
                (
                    [0] =&gt; Array
                        (
                            [id] =&gt; 123_456
                            [from] =&gt; Array
                                (
                                    [name] =&gt; User Name
                                    [id] =&gt; 123
                                )

                            [message] =&gt; This is the message i want to get.
                            [privacy] =&gt; Array
                                (
                                    [value] =&gt; 
                                )

                            [type] =&gt; status
                            [status_type] =&gt; mobile_status_update
                            [created_time] =&gt; 2013-01-13T11:09:55+0000
                            [updated_time] =&gt; 2013-01-13T11:09:55+0000
                            [comments] =&gt; Array
                                (
                                    [count] =&gt; 0
                                )
</code></pre>
