Just nu i M3-nätverket
Jump to content

split


Stefan

Recommended Posts

Hur splittar jag en kommaseparerad string till en array? Stringen ser ut typ så här:

12,43,54,98..... Finns det något liknande explode i PHP?

 

--

Who is General Failure and why is he reading Drive C?

- Unknown

Link to comment
Share on other sites

 

StringTokenizer st = new StringTokenizer("12,43,54,98", ",");

ArrayList al = new ArrayList(st.countTokens());

for(; st.hasMoreTokens(); al.add(st.nextToken()));

String[] array = (String[]) al.toArray(new String[al.size()]);

 

 

Link to comment
Share on other sites

Hann lösa det själv på samma sätt, men det blir poäng ändå! :-)

 

--

Who is General Failure and why is he reading Drive C?

- Unknown

 

Link to comment
Share on other sites

Archived

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



×
×
  • Create New...