title: php iterate multidimesional array with array_map
body: <p>i have an array as below :</p>
  
  <pre><code>array:4 [
    "tag" =&gt; "form"
    "attr" =&gt; array:1 [
      "class" =&gt; array:1 [
        0 =&gt; "form-horizontal"
      ]
    ]
    "text" =&gt; "  "
    "child" =&gt; array:1 [
      0 =&gt; array:3 [
        "tag" =&gt; "fieldset"
        "text" =&gt; "   "
        "child" =&gt; array:1 [
          0 =&gt; array:2 [
            "tag" =&gt; "input"
            "text" =&gt; "input name"
          ]
        ]
      ]
    ]
  ]
  </code></pre>
  
  <p>id like to recreate a new array as below </p>
  
  <pre><code>array[
   0 =&gt; array[
       "input" =&gt; "something",
       "value" =&gt; "somevalue"
     ],
  0 =&gt; array[
       "input" =&gt; "something",
       "value" =&gt; "somevalue"
     ]
  ]
  </code></pre>
  
  <p>if "tag" => "input"  </p>
  
  <p>currently am using below code , laravel based :</p>
  
  <pre><code> public function AjaxData(Request $request)
      {
          //
  
          $array = $request-&gt;json;
          debug($array);
  
  
          $array2 = array_map(array($this, 'sanitize'), $test1 );
  
  
          debug($array2);
          return response()-&gt;json(['name' =&gt; $array['tag'] ]);
  
      }
  
       private function sanitize($value)
      {
  
          return  $value['tag'];
      }
  </code></pre>