note 70187 added to ref.array

From: Date: Fri, 06 Oct 2006 07:17:40 +0000
Subject: note 70187 added to ref.array
Groups: php.notes 
Request: Send a blank email to php-notes+get-118115@lists.php.net to get a copy of this message
A small function to remove an element from a list(numerical array) <?php function array_remove($arr,$value) { return array_values(array_diff($arr,array($value))); } ?> Or, if you don't like that... <?php function array_remove($arr,$value) { if(!in_array($value,$arr)) return $arr; unset($arr[array_search($value,$arr)]); return array_values($arr); } ?> Binny V A http://www.bin-co.com/php/ ---- Server IP: 203.199.124.111 Probable Submitter: 202.88.242.27 ---- Manual Page -- http://www.php.net/manual/en/ref.array.php Edit -- https://master.php.net/note/edit/70187 Del: integrated -- https://master.php.net/note/delete/70187/integrated Del: useless -- https://master.php.net/note/delete/70187/useless Del: bad code -- https://master.php.net/note/delete/70187/bad+code Del: spam -- https://master.php.net/note/delete/70187/spam Del: non-english -- https://master.php.net/note/delete/70187/non-english Del: in docs -- https://master.php.net/note/delete/70187/in+docs Del: other reasons-- https://master.php.net/note/delete/70187 Reject -- https://master.php.net/note/reject/70187 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#118115) next »