Re: unset multidimensional array element [message #180532 is a reply to message #180531] |
Sun, 24 February 2013 01:40 |
cate
Messages: 12 Registered: January 2012
Karma:
|
Junior Member |
|
|
On Feb 23, 7:34 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> On 2/23/2013 8:24 PM, cate wrote:
>
>
>
>
>
>
>
>
>
>> On Feb 23, 7:21 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>>> On 2/23/2013 8:19 PM, cate wrote:
>
>>>> On Feb 23, 7:17 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>>>> > On 2/23/2013 7:18 PM, cate wrote:
>
>>>> >> 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)
>>>> >> )
>
>>>> > All arrays in PHP are associative (hashes). If you remove an element,
>>>> > that key no longer exists.
>
>>>> > You can renumber the array, or you can use operators like foreach(),
>>>> > current(), next(), etc. and not worry about the keys.
>
>>>> > Very seldom do I need to care about the array indexes being in a
>>>> > specific order.
>
>>>> I don't think there is any alternative in php. Thank you.
>
>>> As I said - *in PHP* I very seldom need to care about the array indexes
>>> being in a specific order. There are many ways of doing things with
>>> arrays - and you don't even need a numeric index.
>
>> Never an need for order (mumeric) is quite a statement. :-)
>
> First of all, I said "VERY SELDOM" - not never. There are exceptions.
>
> It's all about knowing the language and using the appropriate features.
> It works quite well.
>
> P.S. Please learn to trim signatures. They shouldn't be copied. Thanks.
lol - It was my CNN mode. Thanks again.
|
|
|