Page is a not externally linkable
- Code, Content, and Presentation
-- PHP Server Side Scripting
---- how to convert txt file into csv using php


londrum - 10:53 am on Apr 17, 2010 (gmt 0)


if the hash lines are uniform across the whole file, then you can use preg_replace to replace every seven hashes with two commas, which will turn them into blank fields.

and i would replace every space with a comma as well, which will take care of most of the rest, but then you will have a problem with their names, because it will split up their christian/middle/surnames.
you'd have to come up with a regular expression which only replaces spaces with commas if one of the characters on either side is a non A-Z character.
im sure one of the brainboxes here will know how to do it.


Thread source:: http://www.webmasterworld.com/php/4116783.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com