re: re: Re: [PHP-GENERAL] Changing the key of an array?

From: Date: Wed, 14 Jun 2000 23:45:29 +0000
Subject: re: re: Re: [PHP-GENERAL] Changing the key of an array?
Groups: php.general 
Request: Send a blank email to php-general+get-1890@lists.php.net to get a copy of this message
I am still using PHP3.0.16 at the moment because I can't get the oracle functions working for the Win32 version of PHP4.0 :( Looks like I am going to have to be patient till someone compiles a working version of PHP4 + Oracle. > At 09:24 AM 6/15/00 +1000, c.just@phoenixdigital.com wrote: > > >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. > > Hello All, > > What version of PHP are you using? > I tried the following code snippet in PHP 4.0.0 on NT and PHP 3.0.12 on BSDi: > > <pre> > <? > $filetypes[""] =34; > $filetypes["a"] =12; > $filetypes["b"] =23; > > var_dump ($filetypes); > unset ($filetypes[""]); > var_dump ($filetypes); > > ?> > > and got the following output for (formatted for your viewing pleasure :): > > array(3) { > [""] => int(34) > ["a"]=> int(12) > ["b"]=> int(23) > } > > array(2) { > ["a"]=> int(12) > ["b"]=>int(23) > } > > In any case, a better solution would be to skip over or re-assign the empty > values. > > HTH, > > > Zak Greant > Creative Director > Nucleus Information Service Inc. > > "I am rather like a mosquito in a nudist camp: I know what I ought to do, > but I don't know where to begin." > - Stephen Bayne >

« previous php.general (#1890) next »