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 need to fiddle more) and the
> array_slice way is just too intensive.
>
> for($counter = 0; $counter < count($listitems);
> $counter++) {
>       if($listitems[$counter] != $item)
>               $newlist .= ",$listitems[$counter]";
> }
> $newlist = substr($newlist, 1, strlen($newlist));
> $listitems = explode("," $newlist);

Why not just do

$newlistitems = array(); // initialize variable
foreach ($listitems as $listitem) {
        if ($listitem != $item) {
                $newlistitems[] = $listitem;
        }
}

This gives you an array called $newlistitems.  Each element in 
$newlistitems is an element from the old $listitems that does not match 
$item.


Erik




----

Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to