×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

where is the data in this function?

where is the data in this function?

where is the data in this function?

(OP)
Wher is the data delimited by the ; in this function please?

CODE

function csv_to_array()
	{
		$delimiter=';';
		$filename='auctions.csv';
		
		if(!file_exists($filename) || !is_readable($filename))
			return FALSE;
		
		$header = NULL;
		$data = array();
		if (($handle = fopen($filename, 'r')) !== FALSE)
		{
			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
			{
				if(!$header)
					$header = $row;
				else
					$data[] = array_combine($header, $row);					
			}
			fclose($handle);
		}
		return $data;
	} 

RE: where is the data in this function?

Quote:

Wher is the data delimited by the ; in this function please?

I don't really understand your question, because the "data" is in the file that is specified in this $filename variable, not in the function.

And if it really is a CSV file (with comma separated values) the delimiter should be a comma ',' not a semicolon ';'

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

RE: where is the data in this function?

(OP)
I can do comma or semi colon, point im making is a need to look at each column of data then wrap in quotes or dont wrap if int i hope thats clear, im goin to use join to put it back together

RE: where is the data in this function?

No idea what you mean,


Can I suggest that you ignore ALL your other threads on this same question and JUST STICK TO ONE of them.



You are confusing yourself and us by flitting from thread to thread with putting a bit of information in each of them.

Pick one to use, then "red flag" the rest for closing or deletion.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

RE: where is the data in this function?

(OP)
I see this has a valid seperate question asking "where is the actual data" thats it, which is the bit that i can foreach($somedate as whateva)
abd echo each comma seperatted bit or does more code needed adding? Im new to php, i use to use asp which i found alot easier to understand but i have to stcik to php because of my platform

"Onward and upward"

RE: where is the data in this function?

Quote:

Im new to php


Which is WHY you need ALL the pertinent information for working out how to handle extracting data from a delimited file, the actual delimiter does not matter. You are jumping about getting bits of information and are having problems putting it all together.

I don't understand what you actually mean by "Wher is the data delimited by the ; in this function please?" because there is no "data in the function". It is a function for extracting the data from a source (a delimited string) and returns that extracted data in the form of an array.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close