PHP 4.0 Bug #8289 Updated: print_r doesn't reset() arrays

From: Date: Mon, 18 Dec 2000 00:37:00 +0000
Subject: PHP 4.0 Bug #8289 Updated: print_r doesn't reset() arrays
Groups: php.dev 
Request: Send a blank email to php-dev+get-41695@lists.php.net to get a copy of this message
ID: 8289 User Update by: cardinal@dodds.net Status: Open Bug Type: Arrays related Description: print_r doesn't reset() arrays In retrospect, the proper thing for print_r to do would be to preserve the array's internal pointer, rather than reset it. This patch seems to do the job. Index: zend.c =================================================================== RCS file: /repository/Zend/zend.c,v retrieving revision 1.102 diff -u -r1.102 zend.c --- zend.c 2000/11/02 23:17:55 1.102 +++ zend.c 2000/12/18 00:35:28 @@ -79,6 +79,7 @@ { zval **tmp; char *string_key; + Bucket *internal_pointer; unsigned long num_key; int i; @@ -87,6 +88,7 @@ } ZEND_PUTS("(\n"); indent += PRINT_ZVAL_INDENT; + internal_pointer = ht->pInternalPointer; zend_hash_internal_pointer_reset(ht); while (zend_hash_get_current_data(ht, (void **) &tmp) == SUCCESS) { for (i=0; i<indent; i++) { @@ -112,6 +114,7 @@ ZEND_PUTS(" "); } ZEND_PUTS(")\n"); + ht->pInternalPointer = internal_pointer; } Previous Comments: --------------------------------------------------------------------------- [2000-12-15 23:15:20] cardinal@dodds.net After using print_r() on an array, the array pointer isn't reset. Affects 4.0.3pl1 and 4.0.4 CVS. $arr['a'] = 'Apple'; $arr['b'] = 'Banana'; $arr['c'] = 'Corn'; print_r($arr); //reset($arr); while(list($k,$v) = each($arr)) echo "$k => $vn"; --------------------------------------------------------------------------- Full Bug description available at: http://bugs.php.net/?id=8289

« previous php.dev (#41695) next »