Page 1 of 1

ignoring commas in individual fields when parsing CSV file

Posted: Wed Apr 19, 2006 6:35 pm
by clem_c_rock
Hello,

I'm trying to develop a bullet proof CSV function that can ignore commas that are found in individual field data when parsing through a regular CSV file.

Here's some of the code I'm trying right now:

Code: Select all

$file = fopen( $file_name, "r" );
$cnt = 0;

while( !feof( $file ))
{   
          $line = fgetcsv( $file, 4096 );
          $count = count( $line );

          if( is_array( $line ) && $count > 0 )
          {
                 for( $i = 0; $i < $count ; $i++ )
                 {
                          echo "<br>$line[$i]  ";
                 }
        }
}
          
 fclose( $file );
Any help you can give would be awesome.

Thanks,
Clem

Posted: Wed Apr 19, 2006 8:20 pm
by feyd
PHP Coding question != General Discussion. :?