From:             [EMAIL PROTECTED]
Operating system: any
PHP version:      4.0.5
PHP Bug Type:     Feature/Change Request
Bug description:  two new array functions

I'd like to propose two new array functions. I currently have the following 
implementation of del() and double() in PHP, but IMHO it would be better to have these 
(or atleast del()) natively in PHP.

When using unset($array[$index]) on array, no re-indexing is performed:

$test = array(1,2,3,4,5,6);

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

The del() method in the floowing code re-indexes the array:

class ftk_array {
    var $data;
    function ftk_array($data=array()) {

    function del($pos) {
        for($i=$pos+1;$i<count($this->data);$i++) {

    function double($pos) {
        for($i=count($this->data);$i>$pos;$i--) {

$test=new ftk_array(array(1,2,3,4,5,6));

The double() method creates a clone of a given array element, while it maintainsthe 
indexes as well.

Edit Bug report at:

PHP Development Mailing List <>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to