-2

I have a string like 12345 and I need to explode it to [1,2,3,4,5]. Normally, I would use split, but there are no separators in here. I could use substr (getting length, making loops), but I will probably have a lot of those strings, so it may not be good for performance. What can I do?

Cœur
  • 34,719
  • 24
  • 185
  • 251
Tomek Buszewski
  • 7,225
  • 10
  • 64
  • 110

1 Answers1

0

Simply use an empty string as a delimiter:

"12345".split('');
Banana
  • 7,380
  • 3
  • 21
  • 42