Re: extracting value from array
| From: | Michael Kelley | Date: | Mon, 30 Jul 2001 21:52:10 +0000 |
| Subject: | Re: extracting value from array | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-8582@lists.php.net to get a copy of this message | ||
Easiest (not best or fastest I'm sure) is Walk through the original array ...
For(i=0,j=0; i < $array.count; i++)
{
//Look for your xyz123 (if its not there write to new array)
if array(i) != "xyz123"
{
$array2(j) = $array(i)
j++
}
} //End For Loop
//you'll now have a "new" array with all the values EXCEPT "xyz123"
I know syntax is not correct .... but you should get the idea of the iteration
afan@sprout.net wrote:
Hi all, my problem is following: let's say there is an array with 10 elements. $array = array('$value1', '$value2', '$value3', '$value4', '$value5', '$value6', '$value7', '$value8', '$value9', '$value10'); 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. Any idea? Afan Pasalic-- Michael Kelley mkelley@nmsu.edu Programmer/Systems Analyst I New Mexico State University Information and Communication Technologies Work # (505)-646-1374 P.O. Box 30001 MSC: 3AT Las Cruces, NM 88003