首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

RegexIterator::accept

(PHP 5 >= 5.2.0, PHP 7)

RegexIterator::accept — Get accept status

Description

代码语言:javascript
复制
public bool RegexIterator::accept ( void )

Matches (string) RegexIterator::current() (or RegexIterator::key() if the RegexIterator::USE_KEY flag is set) against the regular expression.

Parameters

This function has no parameters.

Return Values

TRUE if a match, FALSE otherwise.

Examples

Example #1 RegexIterator::accept() example

This example shows that only items matching the regular expression are accepted.

代码语言:javascript
复制
<?php
$names = new ArrayIterator(array('Ann', 'Bob', 'Charlie', 'David'));
$filter = new RegexIterator($names, '/^[B-D]/');
foreach ($filter as $name) {
    echo $name . PHP_EOL;
}
?>

The above example will output:

代码语言:javascript
复制
Bob
Charlie
David

See Also

  • RegexIterator constants
  • RegexIterator::setFlags() - Sets the flags.

← RegexIterator

RegexIterator::__construct →

代码语言:txt
复制
 © 1997–2017 The PHP Documentation Group

Licensed under the Creative Commons Attribution License v3.0 or later.

扫码关注腾讯云开发者

领取腾讯云代金券