|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2001-06-08 05:48 UTC] jason at sitepoint dot 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
___________________________________
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 07:00:01 2025 UTC |
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 )