tony2001 Tue Sep 19 09:39:14 2006 UTC Added files: (Branch: PHP_4_4) /php-src/ext/standard/tests/array array_walk_objects.phpt
Modified files: /php-src/ext/standard array.c Log: support objects in array_walk() http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.199.2.44.2.11&r2=1.199.2.44.2.12&diff_format=u Index: php-src/ext/standard/array.c diff -u php-src/ext/standard/array.c:1.199.2.44.2.11 php-src/ext/standard/array.c:1.199.2.44.2.12 --- php-src/ext/standard/array.c:1.199.2.44.2.11 Tue Sep 19 09:06:37 2006 +++ php-src/ext/standard/array.c Tue Sep 19 09:39:14 2006 @@ -22,7 +22,7 @@ */ -/* $Id: array.c,v 1.199.2.44.2.11 2006/09/19 09:06:37 tony2001 Exp $ */ +/* $Id: array.c,v 1.199.2.44.2.12 2006/09/19 09:39:14 tony2001 Exp $ */ #include "php.h" #include "php_ini.h" @@ -1028,7 +1028,6 @@ Apply a user function to every member of an array */ PHP_FUNCTION(array_walk) { - int argc; zval *array, *userdata = NULL, *tmp, @@ -1036,7 +1035,7 @@ HashTable *target_hash; old_walk_func_name = BG(array_walk_func_name); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "az|z", &array, &tmp, &userdata) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz|z", &array, &tmp, &userdata) == FAILURE) { return; } target_hash = HASH_OF(array); http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_walk_objects.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/array/array_walk_objects.phpt +++ php-src/ext/standard/tests/array/array_walk_objects.phpt --TEST-- array_walk() and objects --FILE-- <?php function walk($key, $value) { var_dump($value, $key); } class test { private $var_pri = "test_private"; protected $var_pro = "test_protected"; public $var_pub = "test_public"; } $stdclass = new stdclass; $stdclass->foo = "foo"; $stdclass->bar = "bar"; array_walk($stdclass, "walk"); $t = new test; array_walk($t, "walk"); $var = array(); array_walk($var, "walk"); $var = ""; array_walk($var, "walk"); echo "Done\n"; ?> --EXPECTF-- string(3) "foo" string(3) "foo" string(3) "bar" string(3) "bar" string(13) " string(12) "test_private" string(10) " string(14) "test_protected" string(7) "var_pub" string(11) "test_public" Warning: array_walk(): The argument should be an array in %s on line %d Done --UEXPECTF-- unicode(3) "foo" unicode(3) "foo" unicode(3) "bar" unicode(3) "bar" unicode(13) " unicode(12) "test_private" unicode(10) " unicode(14) "test_protected" unicode(7) "var_pub" unicode(11) "test_public" Warning: array_walk(): The argument should be an array in %s on line %d Done -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php