note 13779 deleted from function.array by irc-html

From: Date: Sat, 19 Jan 2002 20:55:19 +0000
Subject: note 13779 deleted from function.array by irc-html
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-25435@lists.php.net to get a copy of this message
OK. What I wanted to do was to remove a value from an array, but PHP doesn't appear to support this as a function. It's not totally comprehensive, as in it will not remove values from indexed arrays, just basic 2D arrays, but I wrote a small function which will remove a supplied value from an array: // Supplied arguments: // ------------------ // removevalue is the value you want removing. // array is the array you want it removing from function arrayremove($removevalue, $array) { $temp_array = $array; unset($array); for ($i=0; $i < sizeof($temp_array); $i++) { if($temp_array[$i] != $removevalue) { $array[] = $temp_array[$i]; } } return $array; } Thanks to mattbeale@ntlworld.com for the initial idea.

« previous php.notes (#25435) next »