Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/php
- <?php
- //BEGIN:VCARD
- //VERSION:2.1
- //N;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:;=49=6C=6C=C3=A9=73;;;
- //FN;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:=49=6C=6C=C3=A9=73
- //TEL;CELL:+36 20 910 7199
- //END:VCARD
- //BEGIN:VCARD
- //VERSION:2.1
- //N;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:;=49=6C=64=69=6B=C3=B3;;;
- //FN;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:=49=6C=64=69=6B=C3=B3
- //TEL;CELL:+36 30 877 7531
- //END:VCARD
- fclose(STDOUT); $STDOUT = fopen('out.valami', 'w');
- define('d',";");
- define('n',"\n");
- $f_=file('2.csv',FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
- foreach($f_ as $i=>$f){
- $x=explode(d,$f);
- if ($i==0) continue;
- // print_r($x);die;
- // 0 => "ker"
- // 1 => "vez"
- // 2 => "work"
- // 3 => "home"
- $k=trim(str_replace('"','',$x[0]));
- $v=trim(str_replace('"','',$x[1]));
- $w=trim(str_replace('"','',$x[2]));
- $h=trim(str_replace('"','',$x[3]));
- print "BEGIN:VCARD
- VERSION:2.1
- N;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:".quoted_printable_encode($v).";".quoted_printable_encode($k).";;;
- FN;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:".quoted_printable_encode($v." ".$k).(empty($w)?"":"
- TEL;WORK:$w").(empty($h)?"":"
- TEL;CELL:$h")."
- END:VCARD".n;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment