PHP Classes

Advice

Recommend this page to a friend!

      phpCSV  >  All threads  >  Advice  >  (Un) Subscribe thread alerts  
Subject:Advice
Summary:Some thoughts about usability
Messages:1
Author:Bolt
Date:2006-03-29 21:02:49
 

  1. Advice   Reply   Report abuse  
Picture of Bolt Bolt - 2006-03-29 21:02:49
I suppose that it's better to use fgets() + explode() then fgetcsv(). It provides the ability to use multi-character delimiters. So I rewrited function readCSV():

function readCSV() {
while(($line = fgets($this->getAttribute('handle'), $this->getAttribute('length'))) !== false) {
$data=explode($this->getAttribute('delimiter'),$line);
$this->addResult($data);
}
}

And one more note - I think it's better to use separate var for results just not to mix with attributes. So i added var $result=array(); in to the beggining of the class and modified function addResult():

function addResult(&$array) {
$this->result[] = $array;
}

Might be useful for somebody )