> But PHP builtins will do exactly this, around 3
> times faster, too. :)
Yup. This one with array_diff was the winner. Thanks
to all for your suggestions and Lars for the working
one.
Liam
__
Do You Yahoo!?
Yahoo! Games - play chess, backgammon,
> -Original Message-
> From: Nathan [mailto:[EMAIL PROTECTED]]
> Sent: 25 April 2002 21:01
>
> Apparently in 4.1.X this is true... I'd been running 4.0.6
> for a long time (until 4.1.2 was
> released), and must have coded it in the earlier version. I
> stand corrected! :-)
H'mmm, I thi
$tmplist[] = $listitems[$i];
> }
> }
> $listitems = $tmplist; //new array contains (grill, bar, world)
> ?>
>
> -Kevin
>
> - Original Message -
> From: "Liam Gibbs" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursda
ing to get. :)
-Kevin
- Original Message -
From: "Liam Gibbs" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, April 25, 2002 2:27 PM
Subject: Re: [PHP] Array function to delete
> Thanks for all your help, everyone, but both
> suggestions (unset and arr
On Thursday, April 25, 2002, at 04:27 PM, Liam Gibbs wrote:
> Thanks for all your help, everyone, but both
> suggestions (unset and array_slice) pretty much didn't
> improve on my current way. I was jsut trying to find a
> faster way, but unset doesn't seem to be working
> properly (but I'll ne
Thanks for all your help, everyone, but both
suggestions (unset and array_slice) pretty much didn't
improve on my current way. I was jsut trying to find a
faster way, but unset doesn't seem to be working
properly (but I'll need to fiddle more) and the
array_slice way is just too intensive.
for($c
for the hardest victory is over self." - Aristotle
> From: Lars Torben Wilson <[EMAIL PROTECTED]>
> Date: 26 Apr 2002 12:50:03 -0700
> To: Pushkar Pradhan <[EMAIL PROTECTED]>
> Cc: Erik Price <[EMAIL PROTECTED]>, Liam Gibbs <[EMAIL PROTECTED]>,
> [EMAIL PROTE
ROTECTED]>
Cc: "Liam Gibbs" <[EMAIL PROTECTED]>; "PHP" <[EMAIL PROTECTED]>
Sent: Friday, April 26, 2002 1:46 PM
Subject: Re: [PHP] Array function to delete
On Thu, 2002-04-25 at 12:34, Nathan wrote:
> No. :-)
>
> What I've had to do is add a dummy valu
On Thu, 2002-04-25 at 12:32, Pushkar Pradhan wrote:
> That's neat but I just read the docs. it says unset() won't work inside a
> function, even if you pass by reference!
No, that is not at all what it says.
> Anyways as far as you don't use functions to do the delete it will work
> fine.
> > On
On Thu, 2002-04-25 at 12:34, Nathan wrote:
> 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
$layer is my array -
$currPos = array_search($HTTP_POST_VARS["selLayer"], $layer);
$arrB = array_slice($layer, $currPos);
$val = array_shift($arrB);
$arrA = array_slice($layer, 0, $currPos);
$layer = array_merge($arrA, $arrB);
// I do this to
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 mes
On Thu, 2002-04-25 at 12:22, Liam Gibbs wrote:
> 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
That's neat but I just read the docs. it says unset() won't work inside a
function, even if you pass by reference!
Anyways as far as you don't use functions to do the delete it will work
fine.
>
> On Thursday, April 25, 2002, at 03:22 PM, Liam Gibbs wrote:
>
> > I've been checking the PHP documen
As far as I know there isn't such a function, what I do to achieve this:
1. find the position of the element you want to remove
2. slice the array into 2 arrays one contains all elements before this and
one contains all elements below this,
3. use shift to remove appropriate element
4. merge both
On Thursday, April 25, 2002, at 03:22 PM, Liam Gibbs wrote:
> 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
16 matches
Mail list logo