Re: Blank Failing

From: Date: Mon, 04 Sep 2000 14:28:03 +0000
Subject: Re: Blank Failing
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-15133@lists.php.net to get a copy of this message
At 16:43 27-1-2000 +0200, Serhat Artun [ Mlist ] wrote:
Hi folks there is a file and there is datas at this format username name surname serial I wrote a script to take username, name and surname from this text and it is working with this format but when I change the format like username name surname serial ( there is two blank character after username ) it cant read if you have an idea please tell me the script is: <?php $file = "/home/db/file.txt"; $fp = fopen ("$file","r"); printf("<table border=1>\n"); printf("<tr>\n"); printf("<td><b>Adi</b></td><td><b>Soyadi</b></td><td><b>GüvenlikNo</b></td>"); printf("</tr>\n"); while (!feof($fp))
    {
      $buffer = chop(trim(fgets($fp,1024)));
      $pieces = explode(" ",$buffer);
$pieces = explode(" ",preg_replace("'[/s]+'", " ", $buffer));
      if (strlen($buffer) > 0) printf("<tr>\n");
      while (list($key,$val) = each($pieces))
        {
           if ( ($key == 0 || $key == 1 || $key == 4) && strlen($val) > 0) printf ("<td>$val</td>",$key,$val);
           flush();
        }
      if (strlen($buffer) > 0) printf("\n</tr>\n");
} printf("</table>\n"); fclose($fp); ?> file is cat /home/db/file.txt Serhat Artun 05322714044 Serial001 Guvenlik001 Ali Kaya 0532120584 Serial004 Guvenlik004 Volkan Erzurumlu 02163026673 Serial020 Guvenlik020


« previous php.general (#15133) next »