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

search for in the

FilterIterator::__construct> <FilterIterator
[edit] Last updated: Fri, 25 May 2012

view this page in

FilterIterator::accept

(PHP 5 >= 5.1.0)

FilterIterator::acceptイテレータの現在の要素がフィルタを満たすかどうかを調べる

説明

abstract bool FilterIterator::accept ( void )

イテレータの現在の要素がこのフィルタを通過するかどうかを返します。

パラメータ

この関数にはパラメータはありません。

返り値

現在の要素が通過する場合に TRUE、それ以外の場合に FALSE を返します。

例1 FilterIterator::accept() の例

<?php
// このイテレータは、10 文字以下の値をすべてフィルタリングします
class LengthFilterIterator extends FilterIterator {

    public function 
accept() {
        
// 長さが 10 文字を超える文字列のみを許可します
        
return strlen(parent::current()) > 10;
    }

}

$arrayIterator = new ArrayIterator(array('test1''more than 10 characters'));
$lengthFilter = new LengthFilterIterator($arrayIterator);

foreach (
$lengthFilter as $value) {
    echo 
$value "\n";
}
?>

上の例の出力は以下となります。

more than 10 characters



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

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