Skip to content

Instantly share code, notes, and snippets.

@koo5
Created January 22, 2012 01:47
Show Gist options
  • Save koo5/1655036 to your computer and use it in GitHub Desktop.
Save koo5/1655036 to your computer and use it in GitHub Desktop.
pohoda <> fio cvs diff
<?php
$fio = array();
$a = fopen("dz-pohyby.cgi", "r");
for($i=0;$i<10;$i++)
fgets($a);
while($b=fgets($a))
$fio[] = explode(";", $b);
$fio=array_splice($fio,0,sizeof($fio)-2);
for($i=0;$i<sizeof($fio);$i++)
$fio[$i] = array(date_create( $fio[$i][1])->getTimestamp(), preg_replace("/ /", "", $fio[$i][2]));
$pohoda = array();
$a = fopen("banka.txt", "r");
while($b=fgets($a))
$pohoda[] = explode(";", $b);
$pohoda=array_splice($pohoda, 1);
for($i=0;$i<sizeof($pohoda);$i++)
{
$p = $pohoda[$i];
$lolatphp=explode(" ",$p[32]);
$pohoda[$i]= array(date_create($lolatphp[0])->getTimestamp(), ($p[15][1]==='V'? "-":""). substr($p[38],0,-3));
}
function cmp($a,$b)
{
if ($a[0] == $b[0])
{
if($a[1]==$b[1])
return 0;
else if ($a[1]<$b[1])
return -1;
else return 1;
}
else if ($a[0]<$b[0])
return -1;
else return 1;
}
//print_r($pohoda);
usort($pohoda, "cmp");
usort($fio, "cmp");
$po = fopen("pohoda", "w");
foreach ($pohoda as $b)
{
$d = getdate($b[0]);
// print_r($d);
fwrite($po, $d['year']." ".$d['mon']." ".$d['mday']." ".$b[1]."\n");
}
$fi = fopen("fio", "w");
foreach ($fio as $b)
{
// print_r($b);
$d =getdate($b[0]);
fwrite($fi, $d['year']." ".$d['mon']." ".$d['mday']." ".$b[1]."\n");
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment