Re: How to remove a value from a array

From: Date: Thu, 02 Aug 2001 20:13:57 +0000
Subject: Re: How to remove a value from a array
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-8634@lists.php.net to get a copy of this message
> let's say there is an array with 10 elements. > One of elements has value 'xyz123' - I do not know which one. > How can I extract this element from the array and > have a new array with all other element, except extracted one. // original array $arr = array("a", "b", "c", "d", "xyz123", "f", "g"); // list of values to remove $remove = array("xyz123"); // do it $result = array_diff($arr, $remove); // show results foreach($result as $val) echo "<br>$val"; "Steen rabøl" <srabol@mail.tele.dk> escribió en el mensaje news:009a01c1098d$049a62f0$0300000a@srjhp... Hi How can I remove a vale from a array() eg; $a = array("1","2","3"); if I then unset($a[1]) the value is NULL, or the offset is empty, and you get a error if yoy try to access that element. What I want/need is a function whic can remove a valy/key from a array Does such a function exists ? Thanks in advance Steen

« previous php.windows (#8634) next »