Re: Array function to delete
| From: | Nathan | Date: | Thu, 25 Apr 2002 19:34:32 +0000 |
| Subject: | Re: Array function to delete | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-94638@lists.php.net to get a copy of this message | ||
No. :-)
What I've had to do is add a dummy value, unset($array[4]) and then array_pop the dummy value
off
the array to get it out of there completely. The reason: unset will only remove $array[4]'s
value,
not the key.
There are plenty of other ways I'm sure, but simply unsetting has really messed me up on
occasion.
I'll unset a value and then implode my array (say a list of numbers), and end up with a string
like
so:
1,233,642,,234,5632,
Where I've unset the 4th and last keys. Which of course really messes up and explode.
# Nathan
----- Original Message -----
From: "Liam Gibbs" <liamgibbs@yahoo.com>
To: <php-general@lists.php.net>
Sent: Thursday, April 25, 2002 1:22 PM
Subject: [PHP] Array function to delete
I've been checking the PHP documentation, but can't
find a function that will delete a member of an array,
like such:
$a = array(1, 2, 3, 4, 5);
Use the function, say array_delete($a, 3); and that
will delete the third member in the array (which would
be 4 above), so that the array would contain 1, 2, 3,
5.
Is there such a function?
__________________________________________________
Do You Yahoo!?
Yahoo! Games - play chess, backgammon, pool and more
http://games.yahoo.com/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php