Last active
December 14, 2015 04:39
-
-
Save mircobabini/5029479 to your computer and use it in GitHub Desktop.
Google contacts vcards cleaner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
require "vcard-extendible.php"; // https://github.com/nuovo/vCard-parser | |
class GCards extends vCard { | |
/** | |
* @return bool | |
*/ | |
public function hasTel () { | |
return (sizeof ($this->tel) > 0); | |
} | |
public function hasMail () { | |
return (sizeof ($this->email) > 0); | |
} | |
} | |
// lot of vcards | |
$cards = new GCards ("cards.vcf"); | |
// var_dump (sizeof ($cards)); | |
$buffer = ""; | |
// $notempty = array (); | |
foreach ($cards as $card) | |
{ | |
if ($card->hasTel () || $card->hasMail ()) | |
{ | |
// $notempty[] = $card; | |
$buffer .= (string)$card; | |
} | |
} | |
// var_dump (sizeof ($notempty)); | |
file_put_contents ('notempty.vcf', $buffer); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment