Конвертация базы

12
tommy-gung
На сайте с 22.11.2006
Offline
287
#11

Dimid, пропустил один символ


$text = file("filename.txt");
$fo = fopen("newfile.txt", "w");

foreach($text as $val) {
$str = explode("|", $val);
if(sizeof($str) == 2) {
fwrite($fo, implode("::", $str));
continue;
}
$line = $str[0]."::".$str[1];
foreach($str as $key=>$sval) {
if($key == 0 or $key == 1) continue;
$line .= "|".$sval;
}
fwrite($fo, $line);
}
fclose($fo);
Здесь не могла быть ваша реклама
A0
На сайте с 22.09.2007
Offline
70
#12

<?php

$input='input.txt';
$output='output.txt';

$input_array=file($input);
$output_array=preg_replace('/\|/','::',$input_array,1);
file_put_contents($output,$output_array);
?>

10 программируемых символов.

12

Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий