zyfpb
注册会员

初级会员
UID 64970
精华
0
积分 146
帖子 104
金钱 146 喜悦币
威望 0
人脉 0
阅读权限 20
注册 2005-6-24
状态 离线
|
[推荐阅读] 变理、数组?
<?php
echo "<meta http-equiv=content-type content=\"text/html\; charset=gb2312\">";
$str="6666";
if (eregi("\d+", $str, $tags)){
echo $tags[0]."<br>";
echo $tags[1]."<br>";
echo $tags[2]."<br>";
//echo $tags[3]."<br>";
//echo $tags[4]."<br>";
// echo $tags[5]."<br>";
}else{
echo "没有匹配";
}
?>
例1:用 \d + 不行,只有用 [0-9]+
<?php
echo "<meta http-equiv=content-type content=\"text/html\; charset=gb2312\">";
$str="singing";
if (eregi("\w+", $str, $tags)){
echo $tags[0]."<br>";
echo $tags[1]."<br>";
echo $tags[2]."<br>";
}else{
echo "没有匹配";
}
?>
例2:用 \w+ 不行, 用 [a-zA-Z0-9]+ 可以
<?php
echo "<meta http-equiv=content-type content=\"text/html\; charset=gb2312\">";
$str="hi";
if (eregi("\bhi\b", $str, $tags)){
echo $tags[0]."<br>";
echo $tags[1]."<br>";
echo $tags[2]."<br>";
}else{
echo "没有匹配";
}
?>
例3: 用 \bhi\b 不行, 用 ^hi$ 才行。
|  用PA做的旅游站http://www.u0855.com |
|