The advantages are:
1. You can define multiple separators at once. When the function is executed, it is cut by a single delimiter rather than by the entire delimiter, while the explode is cut by the entire separator string. As a result, explode can
PHP strtok () function instance application. Compared with explode (), the strtok () function can control the pace. Cut strings as needed. The advantage is: 1. Multiple separators can be defined at a time. When a function is executed, the strtok ()
Both the PHP strtok () function and the explode () function can be used to split a string, but there are some differences between the two, and the Strtok () function can control the rhythm of the explode (), and this article describes in detail the
The Strtok () function can control the rhythm relative to explode (). Cut strings on demand. The advantages are:
1. You can define multiple separators at once. When the function is executed, it is cut by a single delimiter rather than by the entire
// String strtok (string input, string separator );
/*Note that only the first call to strtok uses the string argument. every subsequent call to strtok only needs the token to use, as it keeps track of where it is in the current string. to start
Compared with explode (), the strtok () function can control the pace. Cut strings as needed. When a function is executed, it is cut by a single separator rather than the entire separator, while explode is cut by the entire separator string.
The strtok () function should have been encountered by everyone, but it seems that there are always some problems. Here we will focus on it.
First, let's take a look at the explanations on msdn:
Char * strtok (char * strtoken, const char *
Instance
To split a string by word:
In the following example, note that we used the string parameter only the first time the Strtok () function was called. After the first call, the function only needs the split parameter, because it knows where it
The Strtok () function can control the tempo relative to explode (). Cut strings as needed. Its advantages are: 1, you can define more than one separator at a time. When a function is executed, it is cut by a single delimiter rather than by the
Its advantages are:
1. multiple separators can be defined at a time. When a function is executed, it is cut by a single separator rather than the entire separator, while explode is cut by the entire separator string. Therefore, explode can be cut in
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.