Jump to content


Photo

Cannot crack this..


  • Please log in to reply
4 replies to this topic

#1 glenelkins

glenelkins
  • Members
  • PipPipPip
  • Advanced Member
  • 760 posts
  • LocationBridlington - East Riding of Yorkshire - United Kingdom

Posted 02 August 2006 - 10:56 PM

Im writing a script that should be simple but its becoming a pain. It reads a CSV file line by line, then splits the lines into an array (seperated by commas)

Here is the code
<?
	/* CSV to MYSQL conversion utitliy */
	/* Author: Glen Elkins */
	/* 08/2006 */
	
	// Set variables
	define ("APP_PATH",".");
	define ("CSV_FOLDER","/csv/");
	define ("CSV_FILE","contacts.csv");
	
	// Open The File
	$csv_data = file(APP_PATH.CSV_FOLDER.CSV_FILE);
			
	// Just read the first line to test
             echo $csv_data[0];  -  displays the first line: uid,email,valid,optin,source
	
             $line = $csv_data[0];
	$exploded = explode("&#44;",$line);
	
	echo $exploded[0]; - should display uid but displays uid,email,valid,optin,source 
	
?>

Can anyone see the problem?


http://thewebsolutionprovider.com - A Solution For Everything Web!

#2 nogray

nogray
  • Members
  • PipPipPip
  • Advanced Member
  • 930 posts
  • LocationSan Francisco CA

Posted 02 August 2006 - 10:58 PM

shouldn't "&#44;" be a ","

NoGray.com


#3 glenelkins

glenelkins
  • Members
  • PipPipPip
  • Advanced Member
  • 760 posts
  • LocationBridlington - East Riding of Yorkshire - United Kingdom

Posted 02 August 2006 - 10:59 PM

THat does not work either
http://thewebsolutionprovider.com - A Solution For Everything Web!

#4 glenelkins

glenelkins
  • Members
  • PipPipPip
  • Advanced Member
  • 760 posts
  • LocationBridlington - East Riding of Yorkshire - United Kingdom

Posted 02 August 2006 - 11:00 PM

oh! it does not. for some reason that didnt work before ...
http://thewebsolutionprovider.com - A Solution For Everything Web!

#5 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 02 August 2006 - 11:04 PM

fgetcsv() will save you tons of time
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users