Hi David,

Ran into this myself a short time ago. There's probably a better answer, but I ended using array_diff. Basically I pass in the original array, and a new single element array containing the element to remove, and pocket the difference.

To (kinda) rewrite the manual/online help for this purpose:

|$array1 = array("a" => "green", "red", "blue", "red");
$result = array_diff($array1, array("b" => "green"));

should return $result as containing red, blue and red, but no green.
|
Graham


David Krings wrote:
Hi!

I have an array with numerical keys. I need to remove one element of the array and then rekey the array to have consecutive keys again. I got the rekeying down, but how do I pop off an array element in the middle of an array? Is that done using unset($array[123]) ? I'm having a deer-staring-in-the-headlights-moment.

David
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php


_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php

Reply via email to