Simple foreach loop iteration
<p>I have a really basic problem. I want to iterate through a multidimensional-array. Suppose I want to add an if statement to check values without breaking the foreach loop... my purpose is to get an array of specific values</p>

<pre><code>$foo =  [
     'one'=&gt; [
             'id'=&gt;1,
             'name'=&gt;'32dsfd23'
             ],

    'two' =&gt; [
             'id'=&gt;1,
             'name'=&gt;'322e3'
             ],
    ];

    function new_func($arr){

        $data=[];
        foreach($arr as $val) {

                foreach($val as $key =&gt;$foofoo) {
                    if(array_key_exists('id',$val)){
                    $data['new_arr']=$foofoo;
                }
                }

        }
        return $data;
    }

    echo "&lt;pre&gt;";
    print_r(new_func($foo));
    echo "&lt;/pre&gt;";
</code></pre>

<p>The result is : 
<code>Array
(
    [new_arr] =&gt; 322e3
)</code></p>

<p>And I want to get something like this :<code>
    Array
(
    [new_arr] 
                 [0]=&gt; 32dsfd23,
                 [1]=&gt; 322e3,
)</code></p>