Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
PHP: preg_grep - Manual
[go: Go Back, main page]

PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

preg_last_error" width="11" height="7"/> <パターン構文
Last updated: Sun, 25 Nov 2007

view this page in

preg_grep

(PHP 4, PHP 5)

preg_grep — パターンにマッチする配列の要素を返す

説明

array preg_grep ( string $pattern , array $input [, int $flags ] )

input 配列の要素のうち、 指定した pattern にマッチするものを要素とする配列を返します。

パラメータ

pattern

検索するパターンを表す文字列。

input

入力の配列。

flags

PREG_GREP_INVERT を設定すると、この関数は 与えた pattern にマッチ しない 要素を返します。

返り値

input 配列のキーを使用した配列を返します。

変更履歴

バージョン 説明
4.2.0 パラメータ flags が追加されました。
4.0.4

このバージョンより前は、返される配列の添字は input 配列のキーにかかわらず設定されていました。

以前のこの挙動がお好みの場合は、返される配列に array_values() を適用し、添字を再設定してください。

Example#1 preg_grep() の例

<?php
// すべての浮動小数点数を含む配列要素を返す
$fl_array preg_grep("/^(\d+)?\.\d+$/"$array);
?>



add a note add a note User Contributed Notes
preg_grep
There are no user contributed notes for this page.

 
show source | credits | sitemap | contact | advertising | mirror sites