Whats The use of function strtok() in PHP, how is better than other string function doing the same thing?

OM The Eternity picture OM The Eternity · Mar 27, 2010 · Viewed 10.1k times · Source

Whats the use of function strtok() in PHP? How is better than other string function doing the same thing?

Answer

deceze picture deceze · Mar 27, 2010

There is no other string function that does the same thing. Functions like explode return the complete split string in an array. strtok on the other hand only returns one piece at a time, with each subsequent call returning the next piece. This is potentially much more economic and memory preserving for large strings.