PHP  
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
search for in the  
<PCREpreg_match_all>
Last updated: Mon, 16 Jul 2012

preg_grep

(PHP 4, PHP 5)

preg_grep --  返回与模式匹配的数组单元

说明

array preg_grep ( string pattern, array input )

preg_grep() 返回一个数组,其中包括了 input 数组中与给定的 pattern 模式相匹配的单元。

自 PHP 4.0.4 起,preg_grep() 返回的结果使用从输入数组来的键名进行索引。如果不希望这样的结果,用 array_values()preg_grep() 返回的结果重新索引。

例子 1. preg_grep() 例子

<?php
// return all array elements
// containing floating point numbers
$fl_array = preg_grep ("/^(\d+)?\.\d+$/", $array);
?>




<PCREpreg_match_all>
 Last updated: Mon, 16 Jul 2012
 
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at: http://manual.phpv.net/
Last updated: Thu Jul 7 19:13:47 2005 CST