re: Re: [PHP-GENERAL] Changing the key of an array?
| From: | c dot just at phoenixdigital dot com | Date: | Wed, 14 Jun 2000 23:24:31 +0000 |
| Subject: | re: Re: [PHP-GENERAL] Changing the key of an array? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-1887@lists.php.net to get a copy of this message | ||
Close, veeeery close, but not quite there :(
The thing I should have mentioned was that I was trying to reset a value which got entered into the
associative array like this.
$filetypes[""] =34;
It has a blank key.
I did not set it like above it was set within a loop.
-------------------
# FIND AND RECORD FILE EXTENSION FOR FILE REQUESTS ONLY
if(eregi("([^\./]*)$",$url,$regs)){
$filetypes[$ext]++;
}
-------------------
I am trying to delete the value for the blank key.
When I do this.
unset($filetypes[""]);
It clears the entire array which is not the desired effect.
Thank for pointing out unset( ), I will defeintely find a use for that in other situations.
> would something like
>
> $this[d] = $this[b];
> unset ($this[b]);
>
> work? I'm working from the example so it may not address the problem you have...
>
> hth
>
> Ryan
>
>
> On Thu, Jun 15, 2000 at 07:50:22AM +1000, c.just@phoenixdigital.com wrote:
> >
> > Hi,
> >
> > I am trying to do the following.
> > I have an array
> >
> > $this = array("a"=>"orange", "b"=>"banana",
> > "c"=>"apple");
> >
> > how can I remove the entry
> > $this["b"]
> > and or rename it to
> > $this["d"]
> >
> > I can see that it would use array_splice() but I'm not to sure ow it works when it
> > comes to associative arrays.
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> > For additional commands, e-mail: php-general-help@lists.php.net
> > To contact the list administrators, e-mail: php-list-admin@lists.php.net
> ---end quoted text---
>