- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
function Utf2Win($s){ return Utf8($s,'w') ; }
function Win2Utf($s){ return Utf8($s,'u') ; }
function Utf8($s, $sTo = 'utf2win'){
$a = array();
for ($i=128; $i <= 191; $i++){
$a['utf'][] = ($i<144) ? chr(209).chr($i) : chr(208).chr($i);
$a['win'][] = ($i<144) ? chr($i + 112) : chr($i + 48) ;
}
$a['utf'][] = chr(208) . chr(129);
$a['win'][] = chr(168);
$a['utf'][] = chr(209) . chr(145);
$a['win'][] = chr(184);
$a['utf'][] = chr(209) . chr(78);
$a['win'][] = chr(73);
$a['utf'][] ='в„–';
$a['win'][] = '№';
if(in_array(strtolower($sTo), array('utf2win','w','cp1251','windows-1251')))
return str_replace($a['utf'], $a['win'], $s);
if(in_array(strtolower($sTo), array('win2utf','u','utf8','utf-8')))
return str_replace($a['win'], $a['utf'], $s);
}
function getfield_csv($string,$index)
{
$arr = explode(";",$string);
return $arr[$index];
}
function read_csv($file)
{
$hFile = fopen($file,"r");
$source_data_utf = fread($hFile,filesize($file));
fclose($hFile);
$source_data = Utf2Win($source_data_utf);
$arr_source_data = explode("\r\n",$source_data);
for($i=0;$i<count($arr_source_data);$i++)
{
$arr_source_data[$i] = str_replace(chr(239).chr(187).chr(191), "", $arr_source_data[$i]);
$result[] = Array();
$result[count($result)-1]['Ds'] = getfield_csv($arr_source_data[$i], 0);
$result[count($result)-1]['Fkp'] = getfield_csv($arr_source_data[$i], 5);
$result[count($result)-1]['Tgg'] = getfield_csv($arr_source_data[$i], 3);
$result[count($result)-1]['Pol'] = getfield_csv($arr_source_data[$i], 4);
$result[count($result)-1]['Tr'] = getfield_csv($arr_source_data[$i], 6);
}
return $result;
}
bormand 17.12.2012 10:29 # +5
guest6 16.09.2023 04:34 # 0
anonimb84a2f6fd141 19.12.2012 15:23 # +5
guest8 23.09.2019 22:44 # −999