Home > php教程 > php手册 > 字符处理函数 strtok(string str,string arg)

字符处理函数 strtok(string str,string arg)

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-21 09:07:19
Original
897 people have browsed it

函数

今天用到一个函数,查了一下手册,给出了如下的说明:
Copy after login
<?php $string = "This is\tan example\nstring";$tok = strtok($string," \n\t");while ($tok) {    echo "Word=$tok<br>";    $tok = strtok(" \n\t");}?>
Copy after login
输出:
Copy after login
Word=This
Copy after login
Word=is
Copy after login
Word=an
Copy after login
Word=example
Copy after login
Word=string
Copy after login
这个函数还有自动存储位置的功能,能够在连续的切割字符串取得相应的值,相对于split(string arg)的值
Copy after login
保存在数组中,但其arg却可以是多个字符,而split只能一个字符!
Copy after login
 



Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template