php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #7267 Add an array function...
Submitted: 2000-10-17 00:20 UTC Modified: 2001-01-21 03:41 UTC
From: raulgd at ver dot megared dot net dot mx Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.0.3pl1 OS: linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: raulgd at ver dot megared dot net dot mx
New email:
PHP Version: OS:

 

 [2000-10-17 00:20 UTC] raulgd at ver dot megared dot net dot mx
Hi...
A suggestion...
You should add a function that re-indexes an array, for example...
If I have:
$array = array("one","two","three",3,4,1);
and then I delete one three and 4 then i'll have this left in the array:
$array[1] = two
$array[3] = 3
$array[5] = 1
so if you do a reindexing funct let's say array_reindex() used like this:
array_reindex($array);
then the array will be converted to this:
$array[0] = two
$array[1] = 3
$array[2] = 1
so it reindexes the whole thing because if I use any kind of sort function then it will lose the arrays order and make it 1,3,two instead of two,3,1, or if you know any way that I can reindex an array, please let me know or give me some sample code please
thanks a lot

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-10-17 00:24 UTC] raulgd at ver dot megared dot net dot mx
Hi...
A suggestion...
You should add a function that re-indexes an array, for example...
If I have:
$array = array("one","two","three",1,4,3);
and then I delete one three and 4 then i'll have this left in the array:
$array[1] = two
$array[3] = 1
$array[5] = 3
so if you do a reindexing funct let's say array_reindex() used like this:
array_reindex($array);
then the array will be converted to this:
$array[0] = two
$array[1] = 1
$array[2] = 3
so it reindexes the whole thing because if I use any kind of sort function then it will lose the arrays order and make it 1,3,two instead of two,1,3 or if you know any way that I can reindex an array, please let me know or give me some sample code please
thanks a lot
 [2001-01-21 03:41 UTC] cynic@php.net
use array_values():

$a = array( 'bla' , 3 => 1 , 5 => 3 );
print_r( array_values( $a ) ) ;

Array
(
    [0] => bla
    [1] => 1
    [2] => 3
)


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Feb 23 03:01:30 2024 UTC