<?php
/*
* convert.php
*
* Developed by Ondrej Jombik <nepto@platon.sk>
* Copyright (c) 2008 Platon Group, http://platon.sk/
* Licensed under terms of GNU General Public License.
* All rights reserved.
*
* Changelog:
* 2008-08-03 - created
*
*/
/* $Platon$ */
$contacts = file('nokia-ME.txt');
sort($contacts);
$con_cnt = count($contacts);
for ($cnt = 1, $i = 0; $i < $con_cnt; $i++) {
$line = $contacts[$i];
$line = str_replace(';', '<SEP>', $line);
$line = str_replace('\<SEP>', ';', $line);
$ar = explode('<SEP>', $line);
$name = $ar[0];
$num = $ar[1];
$cgrp = $ar[4];
if (! isset($cgrp) || $cgrp == 5) { // no caller group
continue;
}
$name_array = preg_split('/(\s*,\s*|\s*;\s*|\s+)/i', $name);
for ($j = 0; $j < count($name_array); $j++) {
$name_array[$j] = trim($name_array[$j], " \t\n\r\\.()");
}
$name_array[0] = substr($name_array[0], 0, 4);
$name_array[0] = strtoupper($name_array[0]);
$name_array[1] = substr($name_array[1], 0, 4);
array_push($name_array, substr($num, -3));
$short_name = join('-', $name_array);
if (strlen($short_name) > 13) {
$short_name = preg_replace('/-[^-]*$/', '', $short_name);
}
if (strlen($short_name) > 13) {
$short_name = substr($short_name, 0, 13);
}
echo "$short_name;$num;SM;$cnt;$ar[4];11;0;2;$num\n";
$cnt++;
}
/* Modeline for ViM {{{
* vim: set ts=4:
* vim600: fdm=marker fdl=0 fdc=0:
* }}} */
?>
Platon Group <platon@platon.sk> http://platon.sk/
|