Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #8467

Re: unset multidimensional array element

From "M. Strobel" <sorry_no_mail_here@nowhere.dee>
Newsgroups comp.lang.php
Subject Re: unset multidimensional array element
Date 2013-02-24 14:40 +0100
Message-ID <aoujigFdhp1U1@mid.uni-berlin.de> (permalink)
References <1de87c2e-dd81-475a-8516-85c0885dca9a@p5g2000yqj.googlegroups.com>

Show all headers | View raw


Am 24.02.2013 01:18, schrieb cate:
> Is this correct?
> 
> I remove an element from a multidee array.  Numeric Indexing then
> fails because the it's no longer 0, 1, 2 but instead 0, 2 after the
> unset.   It seems the a numeric index has graduated to a key.  (I
> think I read that's the way php works)
> 
> Do I have to repack this to get sequential indexing to work or is
> there a php way to remove elements and maintain a "numeric" indexs?
> 
> I suppose I could make it a rule to use the construct foreach, but I
> do so love for(;;).
> 
> Thank you in advance.
> 
> 
> array (
>    array (1, 2, 3),
>    array (4, 5, 6),
>    array (7, 8, 9)
> )
> 
This is the behaviour PHP programmers IMO like. Imagine you have a unique database
key as index, I would not like it to be renumbered after deletion of one entry.

/Str.

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

unset multidimensional array element cate <catebekensail@yahoo.com> - 2013-02-23 16:18 -0800
  Re: unset multidimensional array element Jerry Stuckle <jstucklex@attglobal.net> - 2013-02-23 20:17 -0500
    Re: unset multidimensional array element cate <catebekensail@yahoo.com> - 2013-02-23 17:19 -0800
      Re: unset multidimensional array element Jerry Stuckle <jstucklex@attglobal.net> - 2013-02-23 20:21 -0500
        Re: unset multidimensional array element cate <catebekensail@yahoo.com> - 2013-02-23 17:24 -0800
          Re: unset multidimensional array element Jerry Stuckle <jstucklex@attglobal.net> - 2013-02-23 20:34 -0500
            Re: unset multidimensional array element cate <catebekensail@yahoo.com> - 2013-02-23 17:40 -0800
  Re: unset multidimensional array element "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2013-02-24 14:40 +0100
    Re: unset multidimensional array element catebekensail@yahoo.com - 2013-02-24 07:36 -0800
      Re: unset multidimensional array element "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2013-02-24 17:25 +0100
      Re: unset multidimensional array element Captain Paralytic <paul_lautman@yahoo.com> - 2013-02-25 04:01 -0800
      Re: unset multidimensional array element Jerry Stuckle <jstucklex@attglobal.net> - 2013-02-25 11:13 -0500

csiph-web