Jump to content

Strings into an array


point86

Recommended Posts

Hi,

Im fairly new to javascript etc so please be patient! :D

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! :D

Thanks

Point86.

Link to comment
https://forums.phpfreaks.com/topic/29662-strings-into-an-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.