title: Issue renaming directories
body: <p>I want to rename directories of those whose checkbox has been checked by the user with a single click of the <code>Update</code> button. The textbox and checkbox values are collected in an array and sent to the server via jQuery. Firebug shows the correct array values being passed. The problem is that it renames the first checked directory to <code>Array</code> rather than to the new value inputted in the textbox while the other values remain unchanged.</p>
  
  <p>What am I doing wrong in this code?:</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;input type="text" name="album_text[]" id="album_text" class="album_text"  /&gt;
  &lt;input type="text" name="album_text[]" id="album_text" class="album_text"   /&gt;
  &lt;input type="text" name="album_text[]" id="album_text" class="album_text"  /&gt;
  
  &lt;input name="album_checkbox[]" type="checkbox" id="album_checkbox" value="' . $res. '"&gt;
  &lt;input name="album_checkbox[]" type="checkbox" id="album_checkbox" value="' . $res. '"&gt;
  </code></pre>
  
  <p></p>
  
  <p>JQUERY:  </p>
  
  <pre><code>  $("#album_update").click(function() {
                  var album_name = new Array();
  
  
                  $("input[@name='album_checkbox[]']:checked").each(function() {
                      album_name.push($(this).val());
                  });
  
                  var album_text= new Array();
  
                  $("input[name='album_text[]']").each(function(){
  
                      if( $(this).val() ) {
                              album_text.push($(this).val());
                      }
  
                  });  
  
  
  
               var postData = { 
                          "album_name" : album_name,
                          "album_text" : album_text,
                          "album_update" : $("#album_update").val()
                  };   
  
  
                        //make the call
                        $.ajax({
                          type: "POST",
                          url: "updalbums.php",
                          data: postData, 
                          dataType: "json",
                          success: function(data){
                              alert("updated");
                          }
                        });
          });
  </code></pre>
  
  <p>PHP:</p>
  
  <pre><code>public function updateAlbum() {
  
                  if (isset($_POST['album_text']) &amp;&amp; isset($_POST['album_name'])) {
  
                      $path = $_SERVER['DOCUMENT_ROOT'] . '/images/';
  
                      foreach ($_POST['album_name'] as $albums_name ) {
                          $album_text = $_POST['album_text'];
                          rename($path.$albums_name, $path.$album_text); 
                      }
                  }
          }
  </code></pre>