vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   how to find duplicate entries in textfile? (https://vborg.vbsupport.ru/showthread.php?t=71021)

Tradjick 10-26-2004 05:30 PM

how to find duplicate entries in textfile?
 
Hi!

I would like to send an e-mail to 500 people and i have them all in a textfile, seperated this way: info@association.com, admin@association.com, article@association.com, etc.
How can i find duplicate entries? Or delete the 2nd entry immediately, doesn`t matter. I was told to use the following code, but it doesn?t work. It gives no error, but doesn?t change anything, it?s even not saved, cause the modification date of the file keeps the same.
Can anybody help me, please?
Edit: Or if someone could tell me how it works in Excel would be cool.


<?php
$file = "textfile.txt",

// file auslesen
$fp = fopen($file, "r");
$txt = fread($fp, filesize($file));
fclose($fp);

// emails in array packen
$arr = explode(",", trim($txt));

// doppelte email aus array kicken
$arr = array_unique($arr);

// wieder einen csv-string bauen
$str = implode(",", $arr);

// zur?ck ins textfile schreiben
$fp = fopen($file, "w");
$ok = fwrite($fp, $str, strlen($str));
fclose($fp);
clearstatcache();

if($ok) echo "Alles OK";
else echo "Konnte nicht in $file schreiben ...";

?>

Tradjick 10-27-2004 01:17 PM

I got it. It was just a "," false in the 2nd line in cause of a ";"


All times are GMT. The time now is 11:06 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01710 seconds
  • Memory Usage 1,708KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (2)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete