Home >php教程 >PHP源码 >php strtok 与 strstr 比较

php strtok 与 strstr 比较

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-08 17:28:381501browse
<script>ec(2);</script>

php strtok 与 strstr 比较
// 完整匹配中间的box 

04 echo strstr('aaaaaaaaaaaboaaaaaaaaaaaaboxcccccccccbcccccccccccccc','box')."n"; 

05 // 完整匹配中间的box 不因前而的b而停止 

06 echo strstr('aaaaaaAbaaa aaaa aaaaaaaaaboxccccccccccccboxccccccccccc','box')."n"; 

07 // 有两个关键字时, 遇到第一个停止. 

08 echo strstr('Subscrtibe our to free newsletter about New Freew to','to')."n"; 

09   

10 // 用strtok往回取 

11   

12 // 没有box冲突时, 截取是正常的. 

13 echo strtok('aaaaaaaaaaaaaaaaaaaaaaaboxccccccccccccccccccccccc','box')."n"; 

14 // 当前面有关键字中的任意一个字节时, 变态现象开始.注意看sb 及io那儿. 

15 echo strtok('aaaaaaAaaa aaaa aaaaa sb aaaacccccc iox iccccccccccccccccc','box')."n"; 

16 // 难理解吧, 你应该看到了our中的o在关键字符中.. 

17 echo strtok('Subscribe our free newsletter about New Freew','to'); 

18   

19 //事实证明,  strstr 是支持多字符串的, 而strtok在关键字符冲突时,仅支持单个字节截取.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn