| 
	
 | 
 Posted by jerryyang_la1 on 04/07/07 22:41 
I'm reading in a CSV and displaying using the code below: 
 
$users = file("text.txt"); 
   echo "<table border='1' width='75%' align='center'>"; 
   echo "<tr>"; 
      echo "<td width='33%' align='center'><b>Username</b></td>"; 
      echo "<td width='33%' align='center'><b>Domain Name</b></td>"; 
      echo "<td width='34%' align='center'><b>Date & Time</b></td>"; 
      echo "</tr>"; 
   foreach ($users as $user) { 
      list($name, $domain, $date) = explode(",", $user); 
      echo "<tr>"; 
   $result = count($users); 
         if ($domain == " test.com"){ 
	      echo "<td width='33%' align='center'>$font2$name</td>"; 
	      echo "<td width='33%' align='center'>$font2$domain</td>"; 
	      echo "<td width='34%' align='center'>$font2$date</td>"; 
      } else { 
	 echo "<td width='33%' align='center'>$font$name</td>"; 
         echo "<td width='33%' align='center'>$font$domain</td>"; 
         echo "<td width='34%' align='center'>$font$date</td>"; 
      } 
      echo "</tr>"; 
        } 
 
This works fine, except I would like to return the unique value for 
$name, can some one help ? 
 
The CSV is: 
 
username, domain, date 
user1, test.com, 01/02/2007 
 
 
Thanks
 
  
Navigation:
[Reply to this message] 
 |