PHP 4完全中文手册 我形我塑相册 家园常用软件下载 我形我塑相册活动专区 给我留言 我形我塑网站首页
我形我塑,网络相册,www.5x54.com 相册 相册 心情相册,少女相册 免费申请,我形我塑免费相册
 PHP 4 完全中文手册   http://www.5x54.com
 

 


函数:preg_match_all()


preg_match_all

字符串整体比对解析。

语法: int preg_match_all(string pattern, string subject, array matches, int [order]);

返回值: 整数

函数种类: 资料处理

内容说明

本函数以 pattern 的规则来整体解析比对字符串 subject。比对结果返回的值放在数组参数 matches 之中,并依顺序值 order 排序。参数 order 的值有 PREG_PATTERN_ORDER 及 PREG_SET_ORDER 二种。若没有 order 值,则系统自动以 PREG_PATTERN_ORDER 代入 order 值中。返回值为合乎比对结果的数目,若没有或错误则返回 false 值。

使用范例

PREG_PATTERN_ORDER 的例子

<?php
preg_match_all
("|<[^>]+>(.*)</[^>]+>|U""<div align=left>a test</div>"$outPREG_PATTERN_ORDER);
print 
$out[0][0].", ".$out[0][1]."\n";
print 
$out[1][0].", ".$out[1][1]."\n"
?>        

返回值为

<b>example: </b>, <div align=left>this is a test</div>
example: , this is a test




PREG_SET_ORDER 的例子

<?php
preg_match_all
("|<[^>]+>(.*)</[^>]+>|U""<div align=left>a test</div>"$outPREG_SET_ORDER);
print 
$out[0][0].", ".$out[0][1]."\n";
print 
$out[1][0].", ".$out[1][1]."\n"
?>

返回值为           

<b>example: </b>, example: 
<div align=left>this is a test</div>, this is a test


[ 上一页 下一页 ]