preg_match()
<?php
preg_match("/\s*(\S+)\s+(\S.+)/","image/tiff tif tiff;",$matchs);
var_dump($matchs);
array(3) {
[0]=>
string(20) "image/tiff tif tiff;"
[1]=>
string(10) "image/tiff"
[2]=>
string(9) "tif tiff;"
}
- *表示0个或多个
- \s表示空白符号
- \S表示非空白符
- .表示任意字符
- ()表示子表达式
- $matchs 会把所有表达式的值记录下来,包括子表达式