View Single Post
Old 07-13-2006, 11:59 AM   #6 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
redhead is on a distinguished road
Then something like this might be usefull:
Code:
#include <stdio.h>

int main(int argc, char** argv)
{
  FILE *ifp, *ofp;
  int hold_eol = 0;
  char ch;
  if(argc != 3){
    printf("Usage: %s <infile> <outfile>\n", argv[0]);
    return -1;
  }
  if(!(ifp=fopen(argv[1], "r"))){
    printf("Error opening file %s for reading\n", argv[1]);
    return -1;
  }
  if(!(ofp=fopen(argv[2], "w"))){
    printf("Error opening file %s for writing\n", argv[2]);
    return -1;
  }
  while(EOF!=(ch=fgetc(ifp))){
    if(ch == '\"')
      if(hold_eol)
	hold_eol = 0; /* we exit a quote container */
      else
	hold_eol = 1; /* we enter a quote container */
    if(ch == '\n' && hold_eol)
      ch=' '; /* replace eol with space */
    fprintf(ofp, "%c", ch); /* print current char to file */
  }
  fclose(ifp);
  fclose(ofp);
  return 0;
}
I think it is quite easy to transform into some PHP code... Since PHP syntax is very much like C/C++ and the PHP API provides almost identical library functions.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote