test_preg_match_all
<?php
$str = <
<
<
FOO
a: 1
b: 2
c: 3
FOO;
preg_match_all('/(?P<
name>
\w+): (?P<
digit>
\d+)/', $str, $matches);
/* 下面代码在php 5.2.2(pcre 7.0)或更高版本下工作, 不过, 为了向后兼容
* 推荐使用上面的方式. */
// preg_match_all('/(?<
name>
\w+): (?<
digit>
\d+)/', $str, $matches);
print_r($matches);
?>
INFO