Q:

Tracking elements of another array in foreach loop

I have two arrays, $files with file names and $imagesFormats with formats of this images. I want to move every file from $files to directory given in $imageFormats. Indexes of files and it's formats are same in both arrays. What's the best way to do this - creating another associative array ($image => $format) or there is another solution?

A:

If the two array have the same key  you can do in the same foreach  .. eg:
  foreach( $files as $key => $value ) {

        yourfunction($value); /// 
        yourfunction($imagesFormats [$key] ) ;
  }

