Created
January 6, 2011 11:39
-
-
Save jaytaph/767793 to your computer and use it in GitHub Desktop.
MyRegexIterator.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MyNewerRegexIterator extends RegexIterator { | |
public function accept() { | |
$current = $this->current(); | |
if (! isset($current->item)) { | |
return false; | |
} | |
if (preg_match($this->getRegex(), $current->item)) { | |
return true; | |
} | |
return false; | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MyRegexIterator extends RegexIterator { | |
protected $_regex; | |
public function __construct($iterator, $regex, $mode, $flags, $preg_flags ) { | |
$this->_regex = $regex; | |
parent::__construct($iterator, $regex, $mode, $flags, $preg_flags); | |
} | |
public function getRegex() { | |
return $this->_regex; | |
} | |
public function accept() { | |
$current = $this->current(); | |
if (! isset($current->item)) { | |
return false; | |
} | |
if (preg_match($this->getRegex(), $current->item)) { | |
return true; | |
} | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment