Reading file and removing commas

Started on the old forum in December 2017 · view the original in the archive · old links redirect here

2 replies · 63 views · started 8 years ago · 1 min read

3 participants
Michael Connolly Newbie · 2 posts #1

Hi everyone Ive a problem that i need solving essentially i have a file that i want to read from a form using php simple enough and then to add a function to read the file line by line and remove the commas of the text file im relatively new to this and would really really appreciate the help .

i have got this with pseudo code but putting it into action im not sure.

  read file contents into a string find first comma in that string with str_pos, result in $comma while ($comma) {   remove comma from $content using substr   find first comma with str_pos   } result is string without any commas 
sunfighter Newbie · 1 posts #2

I hope you know how to open a file in javascript and read it line by line. The use of the replace() might be the cause of your problem, because it finds and replaces only the first occurrence of the item you want replaced, all other occurrences are untouched. This is the regx method of fixing that.:

<script>
var str = 'the, rain, in, spain';
var newt = str.replace(/,/g, '');
alert(newt);
</script>

If you are having trouble reading the file, come on back and ask me how to do everything.

Sorry, I just saw the posting date. Well lets leave this here maybe it well help somebody.

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close