Re: extracting value from array
| From: | Hugh Bothwell | Date: | Tue, 31 Jul 2001 02:19:22 +0000 |
| Subject: | Re: extracting value from array | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-8584@lists.php.net to get a copy of this message | ||
> <afan@sprout.net> wrote in message
> news:011401c11958$26d38f60$2b43fea9@nyc.rr.com...
> 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";