Bug #11351 Updated: array_shift breaks numeric index key association in PHP4.05

From: Date: Sun, 22 Jul 2001 17:05:10 +0000
Subject: Bug #11351 Updated: array_shift breaks numeric index key association in PHP4.05
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-60636@lists.php.net to get a copy of this message
ID: 11351 Updated by: andy Reported By: jason@sitepoint.com Old Status: Feedback Status: Closed Bug Type: Arrays related Operating System: RH6.2 PHP Version: 4.0.5 New Comment: no feedback after 40+ days. Previous Comments: ------------------------------------------------------------------------ [2001-06-08 14:33:53] sniper@php.net Did this work in 4.0.4pl1? Does it work with the latest RC sources: http://www.php.net/~andi/php-4.0.6RC3.tar.gz --Jani ------------------------------------------------------------------------ [2001-06-08 05:56:01] jason@sitepoint.com This is perhaps more appropriate for posting to the list, please excuse my form. :) <? $my_array = array ( 101 => "Item A", 213 => "Item B", 348 => "Item C", 967 => "Item D", ); print_r($my_array); array_shift($my_array); print_r($my_array); ?> Produces: Array ( [101] => Item A [213] => Item B [348] => Item C [967] => Item D ) Array ( [0] => Item B [1] => Item C [2] => Item D ) ------------------------------------------------------------------------ [2001-06-08 05:48:10] jason@sitepoint.com Hi guys, This is perhaps not a bug, more an anomaly, perhaps. <? $my_array = array ( 0 => "Service ID", 1 => "Daily News Feed", 2 => "Search For Your Site", 3 => "Instant Access to Experts", 4 => "Submit to the Search Engines", 5 => "Link Checker", 6 => "Free Email @yourdomain.com", 7 => "Generate Meta Tags", 9 => "HTML Toolbox", 10 => "Shrink your graphics", 12 => "Cheap Domain Registration", 13 => "Targetted Traffic", 14 => "Community Forums", 15 => "Log Analysis", 20 => "Free, Color, Business Cards", 16 => "Royalty Free Images", 17 => "Search Engine Optimizer", 18 => "Search Engine Starter", 19 => "Web Server Monitor", 21 => "FlashBlaster", 22 => "EchoTools", 23 => "SitePoint Tip Feed", 24 => "Website Appraisal & Benchmark Service" ); print_r($my_array); array_shift($my_array); print_r($my_array); ?> produces the following result (notice that there is no item #8 or #11 in the first list). Notice that all I want to do is remove the first item, whilst keeping the key integrity. What happens is that the data is reindexed and the keys are lost. Perhaps this is desired behaviour? Just thought I'd pop you an email anyway. Array ( [0] => Service ID [1] => Daily News Feed [2] => Search For Your Site [3] => Instant Access to Experts [4] => Submit to the Search Engines [5] => Link Checker [6] => Free Email @yourdomain.com [7] => Generate Meta Tags [9] => HTML Toolbox [10] => Shrink your graphics [12] => Cheap Domain Registration [13] => Targetted Traffic [14] => Community Forums [15] => Log Analysis [20] => Free, Color, Business Cards [16] => Royalty Free Images [17] => Search Engine Optimizer [18] => Search Engine Starter [19] => Web Server Monitor [21] => FlashBlaster [22] => EchoTools [23] => SitePoint Tip Feed [24] => Website Appraisal & Benchmark Service ) Array ( [0] => Daily News Feed [1] => Search For Your Site [2] => Instant Access to Experts [3] => Submit to the Search Engines [4] => Link Checker [5] => Free Email @yourdomain.com [6] => Generate Meta Tags [7] => HTML Toolbox [8] => Shrink your graphics [9] => Cheap Domain Registration [10] => Targetted Traffic [11] => Community Forums [12] => Log Analysis [13] => Free, Color, Business Cards [14] => Royalty Free Images [15] => Search Engine Optimizer [16] => Search Engine Starter [17] => Web Server Monitor [18] => FlashBlaster [19] => EchoTools [20] => SitePoint Tip Feed [21] => Website Appraisal & Benchmark Service ) By the way, did you see our "Building a DataBase Drive Website Using PHP and MySQL" is now the feature article on the front page of MySQL.com? Would PHP.net like to consider something similar? http://www.mysql.com/articles/ddws/index.html http://www.sitepoint.com/article.php/228 Cheers, Jason. ___________________________________ Jason Donald Chief Technology Officer/Co-Founder SitePoint - Master the Web e: jason@sitepoint.com w: www.sitepoint.com p: +613 9495 6600 f: +613 9495 6611 ___________________________________ ------------------------------------------------------------------------ Edit this bug report at http://bugs.php.net/?id=11351&edit=1

« previous php.dev (#60636) next »