Re: Removing elements of multidimensional array
| From: | Erich C. Beyrent | Date: | Thu, 30 Jan 2003 19:00:37 +0000 |
| Subject: | Re: Removing elements of multidimensional array | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-133686@lists.php.net to get a copy of this message | ||
> Hey everyone,
>
> I am reading an ini file into an array using the parse_ini_file() function. What I want to do
> is delete a section from the ini file, and > thought that the best way to do it would be to unset
> one of the keys in the array returned by the parse function. I then want to >
> write the modified array back out to the ini file. I am having a hard time doing the unset
> though - what am I missing?
>
> ***** CODE *****
> // Parse out the events file
> $array = parse_ini_file('./data/events', TRUE);
> while($key = key($array))
> {
> if ($key == $event)
> {
> unset($key);
> next($array);
> }
> else { next($array); }
> }
> // This prints the contents of the array, and the value that I tried to unset is still there...
> print_r($array);
>
> ***** END CODE *****
>
> Thanks!
>
> -Erich-
Never mind. I am SUCH a moron.
// This works just fine...
unset($array[$event]);
-Erich-