php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #14791 Array_shift always the problem ...
Submitted: 2002-01-01 13:20 UTC Modified: 2002-06-17 19:49 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: philippe at beau dot nom dot fr Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.1.1 OS: Linux 2.4.9
Private report: No CVE-ID: None
 [2002-01-01 13:20 UTC] philippe at beau dot nom dot fr
This script : 

<?
	print "before : ";
	for ($i=1;$i<=6;$i++) {
		$toto[$i] = $i;
	}
	print_r($toto);
	print "<br>\n";
	array_shift($toto);
	print "next : ";
	print_r($toto);
	print "<br>\n";	
?>

give this :

before : Array ( [1] => 1 [2] => 2 [3] => 3 [4] => 4 [5] => 5 [6] => 6 ) 
next : Array ( [0] => 2 [1] => 3 [2] => 4 [3] => 5 [4] => 6 ) 

normally i should have :

before : Array ( [1] => 1 [2] => 2 [3] => 3 [4] => 4 [5] => 5 [6] => 6 ) 
next : Array ( [1] => 2 [1] => 3 [2] => 4 [3] => 5 [4] => 6 ) 

Regards,

Philippe BEAU
Email / Philippe--at--beau.nom.Fr

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-01-01 13:23 UTC] philippe at beau dot nom dot fr
Scuse me, a little error by my hands ... ;(

normally i should have :

before : Array ( [1] => 1 [2] => 2 [3] => 3 [4] => 4 [5] => 5 [6] => 6 )

next : Array ( [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 ) 

Regards,

Philippe BEAU
Email / Philippe--at--beau.nom.Fr
 [2002-06-17 09:41 UTC] hholzgra@php.net
array_shift() and unshift() renumber numerical indices
so it's not a but but a feature
-> reclassified as Doc problem
 [2002-06-17 19:49 UTC] hholzgra@php.net
documentation updated in CVS
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed May 07 21:01:30 2025 UTC