FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » arrays with holes
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: arrays with holes [message #176775 is a reply to message #176742] Mon, 23 January 2012 08:38 Go to previous messageGo to previous message
alvaro.NOSPAMTHANX is currently offline  alvaro.NOSPAMTHANX
Messages: 277
Registered: September 2010
Karma:
Senior Member
El 20/01/2012 21:44, cate escribió/wrote:
> On Jan 20, 2:42 pm, cate<catebekens...@yahoo.com> wrote:
>> still! a php newbie. This is kind of a touch base question. I think
>> I have it...
>>
>> I have an indexed array in which I progressively remove elements with
>>
>> unset($my_array[$index]);
>>
>> This leave "holes", which I'm ok with.
>>
>> To now find the 5th element in this shot-up array I use
>>
>> $my_array_piece = array_splice($my_array, 5, 1);
>>
>> Is that how you "do" it?
>>
>> Unfortunately, the "indexes" have meaning. I don't want to repack.
>
> Oops... I mean array_splice($my_array, 4, 1) for the 5th element

If array keys are meaningful but unknown, I can't figure out many other
ways to find for the nth element than array_splice(). But you need to
read the manual page carefully: your code, as is, will get rid of the
key. Check the forth parameter.


--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Parsing .css files with php: Cons?
Next Topic: Open Source Customization
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 28 09:32:52 GMT 2024

Total time taken to generate the page: 0.04192 seconds