title: Multidimensional array key value replacement
body: <p>I have an array I'm trying to change this arrays's some keys but function fails for arrays which are recursive.</p>
  
  <p>What could be problem</p>
  
  <p>Any one can fix this?</p>
  
  <pre><code>$array = array(
      array(
          'tag' =&gt; 'div',
          'class' =&gt; 'lines',
          array(
              'tag' =&gt; 'div',
              'repeat' =&gt; array(
                  'tag' =&gt; 'div',
                   array(
                      'tag' =&gt; 'span',
                      'style' =&gt; 'margin:10px; padding:10px',
                      'key' =&gt; 'title',
                  ),
                  'key' =&gt; 'subject',
              )
          )
      )
  );
  
  
  
  function update_recursively($array, $key = '', $value = array()) {
      //print_r($array); print_r($value);
      foreach ($array as $k =&gt; $v) {
          if ($k === $key){ 
              $array[$k] = $value;
          }
          elseif (is_array($v))
              $array[$k] = update_recursively($v);
      }
      return $array;
  }
  
  print_r(update_recursively($array, 'repeat', array('d' =&gt; 'a')));
  </code></pre>