if((isset($_POST['file']))&&(isset($_POST['parts']))) { // Считываем указанный файл $file = file_get_contents('./arc/'.$_POST['file']); // Можно выбрать любой символ/группу символов для разбивки $p = $_POST['text']; $array = explode($p, $file); $size = sizeof($array); $i = 1; $count = 1; $counter = 0; $part = $size/$_POST['parts']; foreach($array as $str) { $counter++; if(($i<=$part)&&($counter != $size)) { if($i==1) { $fragment .= $str; } else { $fragment .= $p.$str; } $i++; } else { // Выдираем имя файла и его расширение $file = explode('.', $_POST['file']); // Сохраняем в туже директорию с новым именем file_put_contents('./arc/'.$file[0].'_'.$count.'.'.$file[1], $fragment); $fragment = $p; $count++; $i = 1; } } } else { echo '