RE: [PHP] in the middle of shift and pop
| From: | Ford, Mike [LSS] | Date: | Thu, 21 Aug 2003 09:57:08 +0000 |
| Subject: | RE: [PHP] in the middle of shift and pop | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-160289@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Decapode Azur [mailto:blue_prawn@tuxfamily.org]
> Sent: 20 August 2003 23:54
>
> > If you unset an array that isn't associative, will that
ALL PHP arrays are associative. It's just that some arrays have only numeric keys.
> mean there will
> > be a gap in the numbers?
> [snip]----------8<-------------------
>
> > I'm compelled to ask *why* you want that result. In most
> cases it makes
> > no difference to your coding, so the only real reason I can see is a
> > somewhat obsessive desire for neatness!
>
> Perhaps there is a better way to grab the good points to
> build the faces,
> but I did not find another solution yet.
> If you know about another better issue to resolve this
> problem, please let
> me know about it.
Well, I can't really help here without seeing some relevant code. You may be right, and what
you are doing does require no gaps in your keys -- but it may be that you can program round that
more efficently than you can re-index the array when you delete a value.
That said, I'd answer your original question with:
array_splice($arr, $n, 1);
which should actually be pretty efficient!
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@lmu.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211