...

View Full Version : splitting text file into strings and then entering into array



andyl007
12-08-2006, 09:59 PM
Hi,

Im fairly new to javascript etc so please be patient!

Im have a text file which I need to split into strings, and then enter these strings into an arrray.

Thus, I have something like this:

1 hello
2 how are you
3 goodbye

I want to split this into strings (with each line being a new string) and turn this into the following:

a[0] = 'hello'
a[1] = 'how are you'
a[2] = 'goodbye'

Once in the array, the numbers in the original text become unimportant.

Now I know that this can be achieved with an arraylist and possibly a scanner(?). But I dont know the syntax to implement these constructs.

Any help would be much appreciated!

Thanks!

andyl007
12-09-2006, 12:32 PM
Thanks for that, it's really useful! :)

How would I implement this in PHP?

Best

Andy.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum