On Monday 08 April 2002 23:03, Joshua E Minnie wrote: > Can anyone tell me why when the first element in my array would disappear > with the following code: > > <? > //remove the unwanted item from the array > for($i=0;$i<count($stores);$i++) { > $delete=0; > //checking to see if it has been requested for delete > foreach($HTTP_POST_VARS as $val) { > if(is_numeric($val)) { > if($val==$i) $delete = 1; > else continue; > } > else continue; > } > //if not requested for delete, push on to temp array > if($delete == 0) { > array_push($temp, $stores[$i]); > } > } > $stores = $temp; > print_r($stores); > print_r($HTTP_POST_VARS); > ?>
I would rewrite the above as: foreach ($HTTP_POST_VARS as $val) { if(is_numeric($val)) { unset($stores[$val]); } } -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* Don't smoke the next cigarette. Repeat. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php