Re: [PHP] Array remove function?

2007-04-17 Thread Chris
Tijnema ! wrote: On 4/16/07, Jochem Maas [EMAIL PROTECTED] wrote: Richard Lynch wrote: On Wed, April 11, 2007 9:00 pm, Jochem Maas wrote: [PS - I've the pleasure of listening to a colleague do a manual install of Vista over an existing copy of XP and then get the really tricky stuff like

Re: [PHP] Array remove function?

2007-04-16 Thread Jochem Maas
Richard Lynch wrote: On Wed, April 11, 2007 9:00 pm, Jochem Maas wrote: [PS - I've the pleasure of listening to a colleague do a manual install of Vista over an existing copy of XP and then get the really tricky stuff like the soundcard to work ... for the last week :-/] Give them an

Re: [PHP] Array remove function?

2007-04-16 Thread Tijnema !
On 4/16/07, Jochem Maas [EMAIL PROTECTED] wrote: Richard Lynch wrote: On Wed, April 11, 2007 9:00 pm, Jochem Maas wrote: [PS - I've the pleasure of listening to a colleague do a manual install of Vista over an existing copy of XP and then get the really tricky stuff like the soundcard to

Re: [PHP] Array remove function?

2007-04-11 Thread Tijnema !
On 4/10/07, Richard Lynch [EMAIL PROTECTED] wrote: http://php.net/array_flip followed up an unset, followed by another array_flip, I guess... What if you have an array like this: Array ( [0] = Array ( [0] = 1 [1] = 2 [2] = 2 [3] = 2

Re: [PHP] Array remove function?

2007-04-11 Thread Jochem Maas
Paul Novitski wrote: At 4/10/2007 03:09 PM, M.Sokolewicz wrote: Such a function is inherently a Bad Idea (tm). array-values are not unique. Array keys are. So unless you want to emulate the way array_flip works (bad idea (tm)), I'd say: leave it be. Whoever owns that trademark has totally

Re: [PHP] Array remove function?

2007-04-11 Thread Richard Lynch
On Wed, April 11, 2007 8:44 am, Tijnema ! wrote: On 4/10/07, Richard Lynch [EMAIL PROTECTED] wrote: http://php.net/array_flip followed up an unset, followed by another array_flip, I guess... What if you have an array like this: Array ( [0] = Array ( [0] = 1

Re: [PHP] Array remove function?

2007-04-11 Thread Richard Lynch
On Wed, April 11, 2007 9:00 pm, Jochem Maas wrote: [PS - I've the pleasure of listening to a colleague do a manual install of Vista over an existing copy of XP and then get the really tricky stuff like the soundcard to work ... for the last week :-/] Give them an Ubuntu (or similar) CD and

[PHP] Array remove function?

2007-04-10 Thread Tijnema !
Hi, Is there currently a function that removes a key/value from an array? I use this code right now: function array_remove($array,$remove,$remove_value = true) { foreach($array as $key = $value) { if($remove_value $value != $remove) {

Re: [PHP] Array remove function?

2007-04-10 Thread Richard Lynch
http://php.net/unset On Tue, April 10, 2007 2:49 pm, Tijnema ! wrote: Hi, Is there currently a function that removes a key/value from an array? I use this code right now: function array_remove($array,$remove,$remove_value = true) { foreach($array as $key = $value) {

Re: [PHP] Array remove function?

2007-04-10 Thread Tijnema !
On 4/10/07, Richard Lynch [EMAIL PROTECTED] wrote: http://php.net/unset That works when you know the key, but will that work when you only know the value? Tijnema On Tue, April 10, 2007 2:49 pm, Tijnema ! wrote: Hi, Is there currently a function that removes a key/value from an array?

RE: [PHP] Array remove function?

2007-04-10 Thread Daevid Vincent
While that is true, you need to know the key, you could do something like this, which I think is more efficient than your way... foreach($array as $key = $value) { if ($value == $remove) { unset($array[$key]); //if you know there is only one hit,

RE: [PHP] Array remove function?

2007-04-10 Thread Buesching, Logan J
! [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 10, 2007 3:53 PM To: [EMAIL PROTECTED] Cc: PHP Subject: Re: [PHP] Array remove function? On 4/10/07, Richard Lynch [EMAIL PROTECTED] wrote: http://php.net/unset That works when you know the key, but will that work when you only know the value

Re: [PHP] Array remove function?

2007-04-10 Thread Lori Lay
Tijnema ! wrote: On 4/10/07, Richard Lynch [EMAIL PROTECTED] wrote: http://php.net/unset That works when you know the key, but will that work when you only know the value? Tijnema Use array_search() and unset()? Lori On Tue, April 10, 2007 2:49 pm, Tijnema ! wrote: Hi, Is there

RE: [PHP] Array remove function?

2007-04-10 Thread Daevid Vincent
OMG. Now that is the best idea. How simple. Guess I learned something new today too! :) -Original Message- From: Lori Lay [mailto:[EMAIL PROTECTED] Use array_search() and unset()? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:

Re: [PHP] Array remove function?

2007-04-10 Thread tg-php
Unset works, but if he's trying to do a search and remove in one function, unset is a step removed from that criteria (missing the 'search' part). Looking at the array functions, I see some potential. # array_remove(array(1=2,2=3),2,true); // array (2=3) // Keep all but where values = 2

Re: [PHP] Array remove function?

2007-04-10 Thread Tijnema !
On 4/10/07, Daevid Vincent [EMAIL PROTECTED] wrote: OMG. Now that is the best idea. How simple. Guess I learned something new today too! :) -Original Message- From: Lori Lay [mailto:[EMAIL PROTECTED] Use array_search() and unset()? Interesting, I didn't thought of that :) But

Re: [PHP] Array remove function?

2007-04-10 Thread Lori Lay
Tijnema ! wrote: On 4/10/07, Daevid Vincent [EMAIL PROTECTED] wrote: OMG. Now that is the best idea. How simple. Guess I learned something new today too! :) -Original Message- From: Lori Lay [mailto:[EMAIL PROTECTED] Use array_search() and unset()? Interesting, I didn't thought

Re: [PHP] Array remove function?

2007-04-10 Thread Richard Lynch
http://php.net/array_flip followed up an unset, followed by another array_flip, I guess... Why in the world you'd architect the array with a value when you need to unset by value in the first place is beyond me, though... On Tue, April 10, 2007 2:52 pm, Tijnema ! wrote: On 4/10/07, Richard

Re: [PHP] Array remove function?

2007-04-10 Thread M.Sokolewicz
Lori Lay wrote: Tijnema ! wrote: On 4/10/07, Daevid Vincent [EMAIL PROTECTED] wrote: OMG. Now that is the best idea. How simple. Guess I learned something new today too! :) -Original Message- From: Lori Lay [mailto:[EMAIL PROTECTED] Use array_search() and unset()? Interesting,

Re: [PHP] Array remove function?

2007-04-10 Thread Richard Lynch
On Tue, April 10, 2007 3:22 pm, Tijnema ! wrote: On 4/10/07, Daevid Vincent [EMAIL PROTECTED] wrote: OMG. Now that is the best idea. How simple. Guess I learned something new today too! :) -Original Message- From: Lori Lay [mailto:[EMAIL PROTECTED] Use array_search() and

Re: [PHP] Array remove function?

2007-04-10 Thread Paul Novitski
At 4/10/2007 03:09 PM, M.Sokolewicz wrote: Such a function is inherently a Bad Idea (tm). array-values are not unique. Array keys are. So unless you want to emulate the way array_flip works (bad idea (tm)), I'd say: leave it be. Whoever owns that trademark has totally got to be the

Re: [PHP] Array remove function?

2007-04-10 Thread Richard Lynch
On Tue, April 10, 2007 5:39 pm, Paul Novitski wrote: values. If both keys and values are unique, I'd consider (if only briefly) maintaining two arrays, one a flipped version of the other, so I could look up key/value pairs using either node. I do this all the time for small/medium arrays.