note 86191 deleted from function.array-slice by danbrown

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
Note Submitter: businesscatalyst.com
Reason: bad code

----

I tried the arem function provided below and found that when the keys are numeric, a slight modification needs to be made to keep the returned array indices continuous.  Here's my update:
#Remove an element from an array and return the result
function arem($array,$value){
    $holding=array();
    foreach($array as $k => $v){
        if($value!==$v){ //when comparing strings, !== is appropriate here instead of !=
            $holding[]=$v; //removed the key so continuous indexes are preserved.  Put $k back in if the keys need to be preserved.
        }
    }   
    return $holding;
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.