ID:               36154
 User updated by:  dmitriy dot buldakov at etadirect dot com
 Reported By:      dmitriy dot buldakov at etadirect dot com
-Status:           Bogus
+Status:           Open
-Bug Type:         Scripting Engine problem
+Bug Type:         Documentation problem
 Operating System: FreeBSD 5.3
 PHP Version:      4.4.2
 New Comment:

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.


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

[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