Array Question
| From: | Brandt Everett | Date: | Tue, 07 Nov 2000 17:42:23 +0000 |
| Subject: | Array Question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-24141@lists.php.net to get a copy of this message | ||
Here is the code,
(Assume $Underlings is initialized with at least one value.)
1: do {
2: $startingcount = count($Underlings);
3: $flag = false;
4: foreach($Underlings as $val) {
5: $select = "SELECT UserID FROM Users WHERE Supervisor = $val";
6: $resultset = $obj->select($select);
7: if(!empty($resultset)){
8: foreach($resultset as $val2) {
9: if(!in_array($val2["UserID"], $Underlings))
array_push($Underlings, $val2["UserID"]);
10: }
11: } //end if
12: } //end foreach
13: $endingcount = count($Underlings);
14: reset($Underlings);
15:} while( $startingcount != $endingcount);
Here is the question, when I do the array_push() [Line 9:] does that reset
the array pointer which would cause my foreach [Line 4] to act strange.
Strange in that it never touches ever item that is in the array.
Brandt Everett
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
phone: 1-800-398-1232 x 234
e-mail: everett@bentonrea.com
webpage: www.bentonrea.com
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-