Re: Deleting array fields...

From: Date: Wed, 23 Jul 2003 02:45:10 +0000
Subject: Re: Deleting array fields...
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-156373@lists.php.net to get a copy of this message
Thanks Curt. Your suggestion works great. I had come up with this to clear the array, which also worked for me in this instance, by doing this $array['item'] = ""; But I think your suggestion is better because one I have used the array fields once I have no further use for them so I might as well get rid of them. Thanks again. Jason On Tue, 2003-07-22 at 22:36, Curt Zirzow wrote: > * Thus wrote Jason Giangrande (jason@giangrande.org): > > Is there a way to delete array fields without resort the keys? The keys > > of this particular array are the position of the words it holds to their > > position in a string and if they are changed it screws everything up. I > > tried using array_splice but that, unfortunately, rearranges the keys. > > So, to reiterate, what I want to do is remove a key from an array but > > not have the keys automatically reassigned. > > > > Thanks, > > Jason Giangrande > > unset($array['item']); > > I don't think it rearranges it. perhaps the docs should mention this in > the array section. I only remember unset because of a big discussion > about its behavior a while back. > > HTH, > > Curt > -- > "I used to think I was indecisive, but now I'm not so sure."

« previous php.general (#156373) next »