#---------------------------------------------------------------------------
CLASS_DIAGRAMS = YES
HIDE_UNDOC_RELATIONS = YES
-HAVE_DOT = NO
+HAVE_DOT = YES
CLASS_GRAPH = YES
COLLABORATION_GRAPH = YES
-UML_LOOK = NO
+UML_LOOK = YES
TEMPLATE_RELATIONS = NO
INCLUDE_GRAPH = YES
INCLUDED_BY_GRAPH = YES
/**
* @brief Regular expression filter for iterators
* @author Marcus Boerger
- * @version 1.1
+ * @version 1.0
* @since PHP 5.1
*
* This filter iterator assumes that the inner iterator
const GET_MATCH = 1; /**< Mode: Return the first matche (if any) */
const ALL_MATCHES = 2; /**< Mode: Return all matches (if any) */
const SPLIT = 3; /**< Mode: Return the split values (if any) */
+ const REPLACE = 4; /**< Mode: Replace the input key or current */
private $regex; /**< the regular expression to match against */
private $flags; /**< special flags (self::USE_KEY) */
self::GET_MATCH, self::ALL_MATCHES, self::SPLIT) */
private $preg_flags;/**< PREG_* flags, see preg_match(), preg_match_all(),
preg_split() */
+ private $key; /**< the value used for key() */
private $current; /**< the value used for current() */
/**
*
* @param it inner iterator
* @param regex the regular expression to match
- * @param flags special flags (self::USE_KEY)
* @param mode operation mode (one of self::MATCH, self::GET_MATCH,
* self::ALL_MATCHES, self::SPLIT)
+ * @param flags special flags (self::USE_KEY)
* @param preg_flags global PREG_* flags, see preg_match(),
* preg_match_all(), preg_split()
*/
- function __construct(Iterator $it, $regex, $flags = 0, $mode = 0, $preg_flags = 0) {
+ function __construct(Iterator $it, $regex, $mode = 0, $flags = 0, $preg_flags = 0) {
parent::__construct($it);
$this->regex = $regex;
$this->flags = $flags;
function accept()
{
$matches = array();
+ $this->key = parent::key();
$this->current = parent::current();
/* note that we use $this->current, rather than calling parent::current() */
- $subject = ($this->flags & self::USE_KEY) ? parent::key() : $this->current;
+ $subject = ($this->flags & self::USE_KEY) ? $this->key : $this->current;
switch($this->mode)
{
case self::MATCH:
case self::SPLIT:
$this->current = array();
preg_split($this->regex, $subject, $this->current, $this->preg_flags) > 1;
+
+ case self::REPLACE:
+ $this->current = array();
+ $result = preg_replace($this->regex, $this->replacement, $subject);
+ if ($this->flags & self::USE_KEY)
+ {
+ $this->key = $result;
+ }
+ else
+ {
+ $this->current = $result;
+ }
}
}
+ /** @return the key after accept has been called
+ */
+ function key()
+ {
+ return $this->key;
+ }
+
/** @return the current value after accept has been called
*/
function current()
/* }}} */
/* {{{ spl_register_interface */
-void spl_register_interface(zend_class_entry ** ppce, char * class_name, zend_function_entry *functions TSRMLS_DC)
+void spl_register_interface(zend_class_entry ** ppce, char * class_name, zend_function_entry * functions TSRMLS_DC)
{
zend_class_entry ce;
/* }}} */
/* {{{ spl_register_property */
-void spl_register_property( zend_class_entry * class_entry, char *prop_name, zval *prop_val, int prop_flags TSRMLS_DC)
+void spl_register_property( zend_class_entry * class_entry, char *prop_name, int prop_name_len, int prop_flags TSRMLS_DC)
{
- if (!prop_val) {
- INIT_PZVAL(prop_val);
- prop_val->type = IS_NULL;
- }
-
- zend_declare_property(class_entry, prop_name, strlen(prop_name), prop_val, prop_flags TSRMLS_CC);
+ zend_declare_property_null(class_entry, prop_name, prop_name_len, prop_flags TSRMLS_CC);
}
/* }}} */
#define REGISTER_SPL_FUNCTIONS(class_name, function_list) \
spl_register_functions(spl_ce_ ## class_name, function_list TSRMLS_CC);
-#define REGISTER_SPL_PROPERTY(class_name, prop_name) \
- spl_register_property(spl_ce_ ## class_name, prop_name, prop_val, prop_flags TSRMLS_CC);
+#define REGISTER_SPL_PROPERTY(class_name, prop_name, prop_flags) \
+ spl_register_property(spl_ce_ ## class_name, prop_name, sizeof(prop_name)-1, prop_flags TSRMLS_CC);
#define REGISTER_SPL_CLASS_CONST_LONG(class_name, const_name, value) \
zend_declare_class_constant_long(spl_ce_ ## class_name, const_name, sizeof(const_name)-1, (long)value TSRMLS_CC);
void spl_register_parent_ce(zend_class_entry * class_entry, zend_class_entry * parent_class TSRMLS_DC);
void spl_register_functions(zend_class_entry * class_entry, zend_function_entry * function_list TSRMLS_DC);
-void spl_register_property( zend_class_entry * class_entry, char *prop_name, zval *prop_val, int prop_flags TSRMLS_DC);
+void spl_register_property( zend_class_entry * class_entry, char *prop_name, int prop_name_len, int prop_flags TSRMLS_DC);
/* sub: whether to allow subclasses/interfaces
allow = 0: allow all classes and interfaces
case DIT_RegexIterator:
case DIT_RecursiveRegexIterator: {
char *regex;
- int len, poptions, coptions;
- pcre_extra *extra = NULL;
+ int regex_len;
long mode = REGIT_MODE_MATCH;
+ intern->u.regex.use_flags = ZEND_NUM_ARGS() >= 5;
intern->u.regex.flags = 0;
intern->u.regex.preg_flags = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Os|lll", &zobject, ce_inner, ®ex, &len, &intern->u.regex.flags, &mode, &intern->u.regex.preg_flags) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Os|lll", &zobject, ce_inner, ®ex, ®ex_len, &mode, &intern->u.regex.flags, &intern->u.regex.preg_flags) == FAILURE) {
php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
return NULL;
}
return NULL;
}
intern->u.regex.mode = mode;
- intern->u.regex.regex = estrndup(regex, len);
- intern->u.regex.pce = pcre_get_compiled_regex_cache(regex, len, &extra, &poptions, &coptions TSRMLS_CC);
+ intern->u.regex.regex = estrndup(regex, regex_len);
+ intern->u.regex.pce = pcre_get_compiled_regex_cache(regex, regex_len TSRMLS_CC);
intern->u.regex.pce->refcount++;
break;;
}
} /* }}} */
#if HAVE_PCRE || HAVE_BUNDLED_PCRE
-/* {{{ proto void RegexIterator::__construct(Iterator it, string regex [, int flags [, int mode [, int preg_flags]]])
+/* {{{ proto void RegexIterator::__construct(Iterator it, string regex [, int mode [, int flags [, int preg_flags]]])
Create an RegexIterator from another iterator and a regular expression */
SPL_METHOD(RegexIterator, __construct)
{
SPL_METHOD(RegexIterator, accept)
{
spl_dual_it_object *intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
- char *subject, tmp[32];
- int subject_len, use_copy, count;
- zval subject_copy, zcount;
- pcre *regex = intern->u.regex.pce->re;
- pcre_extra *extra = intern->u.regex.pce->extra;
+ char *subject, tmp[32], *result;
+ int subject_len, use_copy, count, result_len;
+ zval subject_copy, zcount, *replacement;
if (intern->u.regex.flags & REGIT_USE_KEY) {
if (intern->current.key_type == HASH_KEY_IS_LONG) {
{
case REGIT_MODE_MAX: /* won't happen but makes compiler happy */
case REGIT_MODE_MATCH:
- count = pcre_exec(regex, extra, subject, subject_len, 0, 0, NULL, 0);
+ count = pcre_exec(intern->u.regex.pce->re, intern->u.regex.pce->extra, subject, subject_len, 0, 0, NULL, 0);
RETVAL_BOOL(count >= 0);
break;
use_copy = 1;
}
zval_ptr_dtor(&intern->current.data);
- MAKE_STD_ZVAL(intern->current.data);
- php_pcre_match(regex, extra, subject, subject_len, &zcount,
- intern->current.data, intern->u.regex.mode == REGIT_MODE_ALL_MATCHES, 0, 0, 0, 0 TSRMLS_CC);
+ ALLOC_INIT_ZVAL(intern->current.data);
+ php_pcre_match_impl(intern->u.regex.pce, subject, subject_len, &zcount,
+ intern->current.data, intern->u.regex.mode == REGIT_MODE_ALL_MATCHES, intern->u.regex.use_flags, intern->u.regex.preg_flags, 0 TSRMLS_CC);
count = zend_hash_num_elements(Z_ARRVAL_P(intern->current.data));
RETVAL_BOOL(count > 0);
break;
use_copy = 1;
}
zval_ptr_dtor(&intern->current.data);
- MAKE_STD_ZVAL(intern->current.data);
- php_pcre_split(regex, extra, subject, subject_len, intern->current.data, 0, -1, 0, 0, 0 TSRMLS_CC);
+ ALLOC_INIT_ZVAL(intern->current.data);
+ php_pcre_split_impl(intern->u.regex.pce, subject, subject_len, intern->current.data, -1, intern->u.regex.preg_flags TSRMLS_CC);
count = zend_hash_num_elements(Z_ARRVAL_P(intern->current.data));
RETVAL_BOOL(count > 1);
break;
+
+ case REGIT_MODE_REPLACE:
+ replacement = zend_read_property(intern->std.ce, getThis(), "replacement", sizeof("replacement")-1, 1 TSRMLS_CC);
+ result = php_pcre_replace_impl(intern->u.regex.pce, subject, subject_len, replacement, 0, &result_len, 0, NULL TSRMLS_CC);
+
+ if (intern->u.regex.flags & REGIT_USE_KEY) {
+ if (intern->current.key_type != HASH_KEY_IS_LONG) {
+ efree(intern->current.str_key);
+ }
+ intern->current.key_type = HASH_KEY_IS_STRING;
+ intern->current.str_key = result;
+ intern->current.str_key_len = result_len + 1;
+ } else {
+ zval_ptr_dtor(&intern->current.data);
+ MAKE_STD_ZVAL(intern->current.data);
+ ZVAL_STRINGL(intern->current.data, result, result_len, 0);
+ }
}
if (use_copy) {
}
} /* }}} */
-/* {{{ proto void RecursiveRegexIterator::__construct(RecursiveIterator it, string regex [, int flags [, int mode [, int preg_flags]]])
+/* {{{ proto void RecursiveRegexIterator::__construct(RecursiveIterator it, string regex [, int mode [, int flags [, int preg_flags]]])
Create an RecursiveRegexIterator from another recursive iterator and a regular expression */
SPL_METHOD(RecursiveRegexIterator, __construct)
{
ZEND_BEGIN_ARG_INFO_EX(arginfo_regex_it___construct, 0, 0, 2)
ZEND_ARG_OBJ_INFO(0, iterator, Iterator, 0)
ZEND_ARG_INFO(0, regex)
- ZEND_ARG_INFO(0, flags)
ZEND_ARG_INFO(0, mode)
+ ZEND_ARG_INFO(0, flags)
ZEND_ARG_INFO(0, preg_flags)
ZEND_END_ARG_INFO();
REGISTER_SPL_CLASS_CONST_LONG(RegexIterator, "GET_MATCH", REGIT_MODE_GET_MATCH);
REGISTER_SPL_CLASS_CONST_LONG(RegexIterator, "ALL_MATCHES", REGIT_MODE_ALL_MATCHES);
REGISTER_SPL_CLASS_CONST_LONG(RegexIterator, "SPLIT", REGIT_MODE_SPLIT);
+ REGISTER_SPL_CLASS_CONST_LONG(RegexIterator, "REPLACE", REGIT_MODE_REPLACE);
+ REGISTER_SPL_PROPERTY(RegexIterator, "replacement", 0);
REGISTER_SPL_SUB_CLASS_EX(RecursiveRegexIterator, RegexIterator, spl_dual_it_new, spl_funcs_RecursiveRegexIterator);
REGISTER_SPL_IMPLEMENTS(RecursiveRegexIterator, RecursiveIterator);
#else
REGIT_MODE_GET_MATCH,
REGIT_MODE_ALL_MATCHES,
REGIT_MODE_SPLIT,
+ REGIT_MODE_REPLACE,
REGIT_MODE_MAX,
} regex_mode;
} append;
#if HAVE_PCRE || HAVE_BUNDLED_PCRE
struct {
+ int use_flags;
int flags;
regex_mode mode;
long preg_flags;
}
$ar = new ArrayIterator(array('1','1,2','1,2,3','',NULL,array(),'FooBar',',',',,'));
-$it = new MyRegexIterator($ar, '/(\d),(\d)/', 0, RegexIterator::GET_MATCH);
+$it = new MyRegexIterator($ar, '/(\d),(\d)/', RegexIterator::GET_MATCH);
$it->show();
-$it = new MyRegexIterator($ar, '/(\d)/', 0, RegexIterator::GET_MATCH);
+$it = new MyRegexIterator($ar, '/(\d)/', RegexIterator::GET_MATCH);
$it->show();
var_dump($ar);
}
$ar = new ArrayIterator(array('1'=>0,'1,2'=>1,'1,2,3'=>2,0=>3,'FooBar'=>4,','=>5,',,'=>6));
-$it = new MyRegexIterator($ar, '/(\d),(\d)/', RegexIterator::USE_KEY, RegexIterator::GET_MATCH);
+$it = new MyRegexIterator($ar, '/(\d),(\d)/', RegexIterator::GET_MATCH, RegexIterator::USE_KEY);
$it->show();
-$it = new MyRegexIterator($ar, '/(\d)/', RegexIterator::USE_KEY, RegexIterator::GET_MATCH);
+$it = new MyRegexIterator($ar, '/(\d)/', RegexIterator::GET_MATCH, RegexIterator::USE_KEY);
$it->show();
var_dump($ar);
int(6)
}
===DONE===
---UEXPECTF--
-unicode(3) "1,2"
-array(3) {
- [0]=>
- string(3) "1,2"
- [1]=>
- string(1) "1"
- [2]=>
- string(1) "2"
-}
-unicode(5) "1,2,3"
-array(3) {
- [0]=>
- string(3) "1,2"
- [1]=>
- string(1) "1"
- [2]=>
- string(1) "2"
-}
-int(1)
-array(2) {
- [0]=>
- string(1) "1"
- [1]=>
- string(1) "1"
-}
-unicode(3) "1,2"
-array(2) {
- [0]=>
- string(1) "1"
- [1]=>
- string(1) "1"
-}
-unicode(5) "1,2,3"
-array(2) {
- [0]=>
- string(1) "1"
- [1]=>
- string(1) "1"
-}
-int(0)
-array(2) {
- [0]=>
- string(1) "0"
- [1]=>
- string(1) "0"
-}
-object(ArrayIterator)#%d (7) {
- [1]=>
- int(0)
- [u"1,2"]=>
- int(1)
- [u"1,2,3"]=>
- int(2)
- [0]=>
- int(3)
- [u"FooBar"]=>
- int(4)
- [u","]=>
- int(5)
- [u",,"]=>
- int(6)
-}
-===DONE===
class MyRegexIterator extends RegexIterator
{
+ public $uk, $re;
+
+ function __construct($it, $re, $mode, $flags = 0)
+ {
+ $this->uk = $flags & self::USE_KEY;
+ $this->re = $re;
+ parent::__construct($it, $re, $mode, $flags);
+ }
+
function show()
{
foreach($this as $k => $v)
var_dump($v);
}
}
+
+ function accept()
+ {
+ @preg_match_all($this->re, (string)($this->uk ? $this->key() : $this->current()), $sub);
+ $ret = parent::accept();
+ var_dump($sub == $this->current());
+ return $ret;
+ }
}
$ar = new ArrayIterator(array('1','1,2','1,2,3','',NULL,array(),'FooBar',',',',,'));
-$it = new MyRegexIterator($ar, '/(\d),(\d)/', 0, RegexIterator::ALL_MATCHES);
+$it = new MyRegexIterator($ar, '/(\d),(\d)/', RegexIterator::ALL_MATCHES);
$it->show();
-$it = new MyRegexIterator($ar, '/(\d)/', 0, RegexIterator::ALL_MATCHES);
+$it = new MyRegexIterator($ar, '/(\d)/', RegexIterator::ALL_MATCHES);
$it->show();
var_dump($ar);
===DONE===
<?php exit(0); ?>
--EXPECTF--
+bool(true)
+int(0)
+array(3) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
+ }
+}
+bool(true)
int(1)
-array(1) {
+array(3) {
[0]=>
- array(3) {
+ array(1) {
[0]=>
string(3) "1,2"
- [1]=>
+ }
+ [1]=>
+ array(1) {
+ [0]=>
string(1) "1"
- [2]=>
+ }
+ [2]=>
+ array(1) {
+ [0]=>
string(1) "2"
}
}
+bool(true)
int(2)
-array(1) {
+array(3) {
[0]=>
- array(3) {
+ array(1) {
[0]=>
string(3) "1,2"
- [1]=>
+ }
+ [1]=>
+ array(1) {
+ [0]=>
string(1) "1"
- [2]=>
+ }
+ [2]=>
+ array(1) {
+ [0]=>
string(1) "2"
}
}
+bool(true)
+int(3)
+array(3) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
+ }
+}
+bool(true)
+int(4)
+array(3) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
+ }
+}
+bool(true)
+int(5)
+array(3) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
+ }
+}
+bool(true)
+int(6)
+array(3) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
+ }
+}
+bool(true)
+int(7)
+array(3) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
+ }
+}
+bool(true)
+int(8)
+array(3) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
+ }
+}
+bool(true)
int(0)
-array(1) {
+array(2) {
[0]=>
- array(2) {
+ array(1) {
[0]=>
string(1) "1"
- [1]=>
+ }
+ [1]=>
+ array(1) {
+ [0]=>
string(1) "1"
}
}
+bool(true)
int(1)
array(2) {
[0]=>
[0]=>
string(1) "1"
[1]=>
- string(1) "1"
+ string(1) "2"
}
[1]=>
array(2) {
[0]=>
- string(1) "2"
+ string(1) "1"
[1]=>
string(1) "2"
}
}
+bool(true)
int(2)
-array(3) {
+array(2) {
[0]=>
- array(2) {
+ array(3) {
[0]=>
string(1) "1"
[1]=>
- string(1) "1"
+ string(1) "2"
+ [2]=>
+ string(1) "3"
}
[1]=>
- array(2) {
+ array(3) {
[0]=>
- string(1) "2"
+ string(1) "1"
[1]=>
string(1) "2"
- }
- [2]=>
- array(2) {
- [0]=>
- string(1) "3"
- [1]=>
+ [2]=>
string(1) "3"
}
}
+bool(true)
+int(3)
+array(2) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+}
+bool(true)
+int(4)
+array(2) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+}
+bool(true)
+int(5)
+array(2) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+}
+bool(true)
+int(6)
+array(2) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+}
+bool(true)
+int(7)
+array(2) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+}
+bool(true)
+int(8)
+array(2) {
+ [0]=>
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+}
object(ArrayIterator)#%d (9) {
[0]=>
%s(1) "1"
--TEST--
-SPL: RegexIterator::ALL_MATCHES, USE_KEY
+SPL: RegexIterator::ALL_MATCHES
--SKIPIF--
<?php if (!extension_loaded("spl")) print "skip"; ?>
--FILE--
class MyRegexIterator extends RegexIterator
{
+ public $uk, $re;
+
+ function __construct($it, $re, $mode, $flags = 0)
+ {
+ $this->uk = $flags & self::USE_KEY;
+ $this->re = $re;
+ parent::__construct($it, $re, $mode, $flags);
+ }
+
function show()
{
foreach($this as $k => $v)
var_dump($v);
}
}
+
+ function accept()
+ {
+ @preg_match_all($this->re, (string)($this->uk ? $this->key() : $this->current()), $sub);
+ $ret = parent::accept();
+ var_dump($sub == $this->current());
+ return $ret;
+ }
}
-$ar = new ArrayIterator(array('1'=>0,'1,2'=>1,'1,2,3'=>2,0=>3,'FooBar'=>4,','=>5,',,'=>6));
-$it = new MyRegexIterator($ar, '/(\d),(\d)/', RegexIterator::USE_KEY, RegexIterator::ALL_MATCHES);
+$ar = new ArrayIterator(array('1','1,2','1,2,3','',NULL,array(),'FooBar',',',',,'));
+$it = new MyRegexIterator($ar, '/(\d),(\d)/', RegexIterator::ALL_MATCHES, RegexIterator::USE_KEY);
$it->show();
-$it = new MyRegexIterator($ar, '/(\d)/', RegexIterator::USE_KEY, RegexIterator::ALL_MATCHES);
+$it = new MyRegexIterator($ar, '/(\d)/', RegexIterator::ALL_MATCHES, RegexIterator::USE_KEY);
$it->show();
var_dump($ar);
===DONE===
<?php exit(0); ?>
--EXPECTF--
-string(3) "1,2"
-array(1) {
+bool(true)
+int(0)
+array(3) {
[0]=>
- array(3) {
- [0]=>
- string(3) "1,2"
- [1]=>
- string(1) "1"
- [2]=>
- string(1) "2"
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
}
}
-string(5) "1,2,3"
-array(1) {
+bool(true)
+int(1)
+array(3) {
[0]=>
- array(3) {
- [0]=>
- string(3) "1,2"
- [1]=>
- string(1) "1"
- [2]=>
- string(1) "2"
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
}
}
-int(1)
-array(1) {
+bool(true)
+int(2)
+array(3) {
[0]=>
- array(2) {
- [0]=>
- string(1) "1"
- [1]=>
- string(1) "1"
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
}
}
-string(3) "1,2"
-array(2) {
+bool(true)
+int(3)
+array(3) {
[0]=>
- array(2) {
- [0]=>
- string(1) "1"
- [1]=>
- string(1) "1"
+ array(0) {
}
[1]=>
- array(2) {
- [0]=>
- string(1) "2"
- [1]=>
- string(1) "2"
+ array(0) {
+ }
+ [2]=>
+ array(0) {
}
}
-string(5) "1,2,3"
+bool(true)
+int(4)
array(3) {
[0]=>
- array(2) {
- [0]=>
- string(1) "1"
- [1]=>
- string(1) "1"
+ array(0) {
}
[1]=>
- array(2) {
- [0]=>
- string(1) "2"
- [1]=>
- string(1) "2"
+ array(0) {
}
[2]=>
- array(2) {
- [0]=>
- string(1) "3"
- [1]=>
- string(1) "3"
+ array(0) {
}
}
-int(0)
-array(1) {
+bool(true)
+int(5)
+array(3) {
[0]=>
- array(2) {
- [0]=>
- string(1) "0"
- [1]=>
- string(1) "0"
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
}
}
-object(ArrayIterator)#%d (7) {
+bool(true)
+int(6)
+array(3) {
+ [0]=>
+ array(0) {
+ }
[1]=>
- int(0)
- ["1,2"]=>
- int(1)
- ["1,2,3"]=>
- int(2)
+ array(0) {
+ }
+ [2]=>
+ array(0) {
+ }
+}
+bool(true)
+int(7)
+array(3) {
[0]=>
- int(3)
- ["FooBar"]=>
- int(4)
- [","]=>
- int(5)
- [",,"]=>
- int(6)
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
+ }
}
-===DONE===
---UEXPECTF--
-unicode(3) "1,2"
-array(1) {
+bool(true)
+int(8)
+array(3) {
[0]=>
- array(3) {
- [0]=>
- string(3) "1,2"
- [1]=>
- string(1) "1"
- [2]=>
- string(1) "2"
+ array(0) {
+ }
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
}
}
-unicode(5) "1,2,3"
-array(1) {
+bool(true)
+int(0)
+array(2) {
[0]=>
- array(3) {
+ array(1) {
[0]=>
- string(3) "1,2"
- [1]=>
- string(1) "1"
- [2]=>
- string(1) "2"
+ string(1) "0"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(1) "0"
}
}
+bool(true)
int(1)
-array(1) {
+array(2) {
[0]=>
- array(2) {
+ array(1) {
[0]=>
string(1) "1"
- [1]=>
+ }
+ [1]=>
+ array(1) {
+ [0]=>
string(1) "1"
}
}
-unicode(3) "1,2"
+bool(true)
+int(2)
array(2) {
[0]=>
- array(2) {
+ array(1) {
[0]=>
- string(1) "1"
- [1]=>
- string(1) "1"
+ string(1) "2"
}
[1]=>
- array(2) {
+ array(1) {
[0]=>
string(1) "2"
- [1]=>
- string(1) "2"
}
}
-unicode(5) "1,2,3"
-array(3) {
+bool(true)
+int(3)
+array(2) {
[0]=>
- array(2) {
+ array(1) {
[0]=>
- string(1) "1"
- [1]=>
- string(1) "1"
+ string(1) "3"
}
[1]=>
- array(2) {
+ array(1) {
[0]=>
- string(1) "2"
- [1]=>
- string(1) "2"
+ string(1) "3"
}
- [2]=>
- array(2) {
+}
+bool(true)
+int(4)
+array(2) {
+ [0]=>
+ array(1) {
[0]=>
- string(1) "3"
- [1]=>
- string(1) "3"
+ string(1) "4"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(1) "4"
}
}
-int(0)
-array(1) {
+bool(true)
+int(5)
+array(2) {
[0]=>
- array(2) {
+ array(1) {
[0]=>
- string(1) "0"
- [1]=>
- string(1) "0"
+ string(1) "5"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(1) "5"
}
}
-object(ArrayIterator)#%d (7) {
+bool(true)
+int(6)
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(1) "6"
+ }
[1]=>
- int(0)
- [u"1,2"]=>
- int(1)
- [u"1,2,3"]=>
- int(2)
+ array(1) {
+ [0]=>
+ string(1) "6"
+ }
+}
+bool(true)
+int(7)
+array(2) {
[0]=>
- int(3)
- [u"FooBar"]=>
- int(4)
- [u","]=>
- int(5)
- [u",,"]=>
- int(6)
+ array(1) {
+ [0]=>
+ string(1) "7"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(1) "7"
+ }
+}
+bool(true)
+int(8)
+array(2) {
+ [0]=>
+ array(1) {
+ [0]=>
+ string(1) "8"
+ }
+ [1]=>
+ array(1) {
+ [0]=>
+ string(1) "8"
+ }
+}
+object(ArrayIterator)#%d (9) {
+ [0]=>
+ %s(1) "1"
+ [1]=>
+ %s(3) "1,2"
+ [2]=>
+ %s(5) "1,2,3"
+ [3]=>
+ %s(0) ""
+ [4]=>
+ NULL
+ [5]=>
+ array(0) {
+ }
+ [6]=>
+ %s(6) "FooBar"
+ [7]=>
+ %s(1) ","
+ [8]=>
+ %s(2) ",,"
}
===DONE===
}
$ar = new ArrayIterator(array('1','1,2','1,2,3','',NULL,array(),'FooBar',',',',,'));
-$it = new MyRegexIterator($ar, '/,/', 0, RegexIterator::SPLIT);
+$it = new MyRegexIterator($ar, '/,/', RegexIterator::SPLIT);
$it->show();
}
$ar = new ArrayIterator(array('1'=>0,'1,2'=>1,'1,2,3'=>2,0=>3,'FooBar'=>4,','=>5,',,'=>6));
-$it = new MyRegexIterator($ar, '/(\d),(\d)/', RegexIterator::USE_KEY, RegexIterator::SPLIT);
+$it = new MyRegexIterator($ar, '/(\d),(\d)/', RegexIterator::SPLIT, RegexIterator::USE_KEY);
$it->show();
int(6)
}
===DONE===
---UEXPECTF--
-unicode(3) "1,2"
-array(2) {
- [0]=>
- string(0) ""
- [1]=>
- string(0) ""
-}
-unicode(5) "1,2,3"
-array(2) {
- [0]=>
- string(0) ""
- [1]=>
- string(2) ",3"
-}
-object(ArrayIterator)#%d (7) {
- [1]=>
- int(0)
- [u"1,2"]=>
- int(1)
- [u"1,2,3"]=>
- int(2)
- [0]=>
- int(3)
- [u"FooBar"]=>
- int(4)
- [u","]=>
- int(5)
- [u",,"]=>
- int(6)
-}
-===DONE===