$file =array(1=>file('text.txt'),2=>file("text2.txt"),...); foreach($file as $id=>$value){ echo $id . ' = ' . $value; }