Okay, so I don't even really know how to phrase this question. I'm essentially writing the results of a query to a tab delimited file but my boss has requested that the file also contain the column headers.
So, I can pull all of the column headers with mysql_field_name and then append a tab to each one. My problem is I need to be able to tell when I've reached the last column header and instead of appending a tab, append a newline. Here's what I'm toying with so far. Any help is appreciated.
while ($i < mysql_num_fields($resultSelect)){
$fieldname = mysql_field_name($resultSelect, $i);
if (strchr($fieldname, '') !==FALSE) {
$fieldname = $fieldname . "\t";
} else {
$fieldname = $fieldname . "\n";
}
fputs($fileput, $fieldname);
$i++;
}
So, strchr does not work. Any ideas on what to use?