Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_php thread: fgetcsv() problem


Message #1 by "David Scott-Bigsby" <DScott-Bigsby@P...> on Wed, 26 Jun 2002 13:27:56 -0700
PHP Pros,

An odd thing happened to me today. I was reading in a CSV file using 
fgetcsv() and, after about 30 lines, the file pointer reverted to the 
start of the file again, i.e., lines were read in more than once.

Here's the essential code:

	if ( ! ($fp =3D fopen( $file, 'r' )) )
	{
		$gaResults[$file] =3D "Could not open to read";
	}
	else
	{
		$i=3D0;
		$gaResults[$file][$i] =3D "Opened to read";
	=09
		while ( ! feof($fp) )
		// for each line in the file...
		{
			// do some stuff, including a call to feof() to
		=09
		} // end while loop through file
	=09
		/*
			Close the file and make the backup copy
		*/
		if ( ! fclose( $fp ) )
		{
			// handle error	=09
		}
	}


Any thoughts on why fgetcsv() might behave this way?

thanks,

dsb

***************************************       
David Scott-Bigsby
Product Manager, Web Site and PEDN

PureEdge Solutions
The Leader in Secure XML e-Forms

v:250-708-8145  f:250-708-8010
1-888-517-2675   www.PureEdge.com
***************************************

  Return to Index