php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35501 array storage and access
Submitted: 2005-12-01 12:40 UTC Modified: 2005-12-01 13:12 UTC
From: robing9 at yahoo dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5.0.4 OS: Windows XP SP2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
47 - 17 = ?
Subscribe to this entry?

 
 [2005-12-01 12:40 UTC] robing9 at yahoo dot com
Description:
------------
I am working with a uniserver with  Apache 2.0.54, ActivePerl 5.8.7.813, PHP 5.0.4, MySQL 4.1.12a, phpMyAdmin-2.6.3-rc1 

When I stored some data in a array with key field in integer but in a jumbled manner (insted of 1,2,3,4 as the key values i gave 0,1,4,2,3).
Then when i printed it using the print_r function I got the data in the order of the key values 0,1,4,2,3.
But shouldn't it have come in the order 0,1,2,3,4?

I have written the code below.
********************************
PS : I couldnt find a relevant PHP version so I selected 5CVS 2005-12-01(snap)

Reproduce code:
---------------
<?php
$x[0] = 'robin';
$x[1] = 'tony';
$x[4] = 'Sini';
$x[2] = 'pradeep';
$x[3] = 'prem';

print_r($x);
?>



Expected result:
----------------
Array ( [0] => robin [1] => tony [2] => pradeep [3] => prem [4] => Sini ) 

Actual result:
--------------
Array ( [0] => robin [1] => tony [4] => Sini [2] => pradeep [3] => prem ) 


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-12-01 13:12 UTC] sniper@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 22:01:28 2024 UTC