Re: Re: Delete element from an array (PHP3)
| From: | Richard Lynch | Date: | Sat, 06 Oct 2001 22:55:08 +0000 |
| Subject: | Re: Re: Delete element from an array (PHP3) | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-70259@lists.php.net to get a copy of this message | ||
It's a known issue, but I could have sworn there was an easy work-around...
Try checking out what the value is, if isset() works properly, or if
list/each works right.
*SOME* combination of code is safe cross-platform, IIRC...
--
WARNING richard@zend.com address is an endangered species -- Use
ceo@l-i-e.com
Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm
----- Original Message -----
From: John Steele <overlord@visionww.com>
To: Richard Lynch <ceo@l-i-e.com>; <php-general@lists.php.net>
Sent: Saturday, October 06, 2001 6:04 AM
Subject: Re: [PHP] Re: Delete element from an array (PHP3)
> Richard,
>
> Unfortunately unset() isn't working for this on two different versions
of PHP3 that I've tried. It seems the element is empty, but the reference
is still there. Something seems to have changed in PHP4 when passing a
multi-dimensioned array to a function and calling unset() on an element...
>
> >unset() should work...
> >
> >There were (beta?) versions where it would leave behind some detrius, but
> >IIRC, you were safe if you used list/each...
> >
> >> In PHP4, unset($myarray['3']['someindex'}) removes this element
(inside
> >a class function passed $myarray). I need to do the same for PHP3 - what
is
> >the simplest way to accomplish this?
> >>
> >> I guess I'm looking for a function that supports PHP3 or PHP4, say:
> >>
> >> function unset_arr ($array) {
> >> if (phpversion() < 4)
> >> // get rid of the array element here...
> >> else
> >> unset ($array);
> >> }
> >>
> >> I'm assuming that I will have to do some shuffling of the array, and
> >possibly return a new array with that element missing?
> >>
> >> Thanks for any help on this,
> >> John
>
> --
> /* SteeleSoft Consulting John Steele - Systems Analyst/Programmer
> * We also walk dogs... PHP/MySQL/Linux/Hosting - jsteele@writeme.com
> * http://www.steelesoftconsulting.com
> */