ID:               36154
 Updated by:       [EMAIL PROTECTED]
 Reported By:      dmitriy dot buldakov at etadirect dot com
-Status:           Open
+Status:           Closed
 Bug Type:         Documentation problem
 Operating System: FreeBSD 5.3
 PHP Version:      4.4.2
 New Comment:

This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation
better.

"It also means that the internal array pointer used by current() and
similar functions is reset."


Previous Comments:
------------------------------------------------------------------------

[2006-01-25 13:26:33] dmitriy dot buldakov at etadirect dot com

Dear Sniper. 
I checked documentaion twice before the first reporting. 
So, I checked triply before this mail. 
 
There are no any phrase "cursor" or "pointer" on 
http://www.php.net/manual/en/language.types.array.php and 
http://www.php.net/manual/ru/language.types.array.php. 
And there is only one prase about "array assignment" -  
"You should be aware that array assignment always involves 
value copying. You need to use the reference operator to 
copy an array by reference" 
 
Also, there are no any phrase about cursor (or pointer) 
behavior in case of array assignment  on 
http://www.php.net/manual/en/ref.array.php and on reset, 
end, next, prev, current, pos, key, each functions 
description pages. 
 
Perhaps I am not skilled in text reading, but I am sure 
that the "not a bug" dose not described in a sensible 
section of the manual. 
 
Please check also.

------------------------------------------------------------------------

[2006-01-25 10:46:36] [EMAIL PROTECTED]

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php



------------------------------------------------------------------------

[2006-01-25 10:18:14] dmitriy dot buldakov at etadirect dot com

Description:
------------
In case of assignment to a variable another variable that contains an
array with positioned cursor the old array loses cursor position but
array in new variable cathes it.

I think - the initial array ($a) cursor should be untouched.
The copied array ($c) cursor can be copied or reset, but its behavior
should be documented.

Reproduce code:
---------------
<?php

  $a = array(1,2,3,4,5,6,7);

  $b = $a;

  next($a);

  print 'next($a); ...'."\n";
  print ' current($a) = '.current($a)."\n";
  print ' current($b) = '.current($b)."\n";

  $c = $a;

  print '$c = $a; ...'."\n";
  print ' current($a) = '.current($a)."\n";
  print ' current($b) = '.current($b)."\n";
  print ' current($c) = '.current($c)."\n";

?>

Expected result:
----------------
bash-3.00# php test.php
next($a); ...
 current($a) = 2
 current($b) = 1
$c = $a; ...
 current($a) = 2
 current($b) = 1
 current($c) = 1
bash-3.00#

or

bash-3.00# php test.php
next($a); ...
 current($a) = 2
 current($b) = 1
$c = $a; ...
 current($a) = 2
 current($b) = 1
 current($c) = 2
bash-3.00#



Actual result:
--------------
bash-3.00# php test.php
next($a); ...
 current($a) = 2
 current($b) = 1
$c = $a; ...
 current($a) = 1
 current($b) = 1
 current($c) = 2
bash-3.00#



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=36154&edit=1

Reply via email to