Re: [PHP] Array elements missing
Thanks for the suggestion. I did get it to work prior to your posting, but this does help slim up my code quite a bit. -- Joshua E Minnie CIO [EMAIL PROTECTED] Don't work for recognition, but always do work worthy of recognition. Jason Wong [EMAIL PROTECTED] wrote: 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;$icount($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
[PHP] Array elements missing
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;$icount($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); ? Here is the output of the print_r's: Array ( [0] = [1] = Array ( [0] = AR [1] = 1 [2] = 1059 11th St. [3] = Grand Rapids [4] = (233) 457-2394 [5] = (233) 457-4982 [6] = [7] = [8] = ) [2] = Array ( [0] = AR [1] = 2 [2] = 1059 11th St. [3] = Grand Rapids [4] = (233) 457-2394 [5] = (233) 457-4982 [6] = [7] = [8] = ) [3] = Array ( [0] = LA [1] = 3 [2] = 1174 Gernaat Ct. [3] = Delton [4] = (233) 457-2394 [5] = (233) 457-4982 [6] = [7] = [8] = ) [4] = Array ( [0] = ME [1] = 4 [2] = 1059 11th St. [3] = Delton [4] = (233) 457-2394 [5] = (233) 457-4982 [6] = [7] = [8] = ) [5] = Array ( [0] = MI [1] = 6 [2] = 437 4th Ave. [3] = Yet Another City [4] = (123) 283-4839 [5] = (123) 458-4843 [6] = [7] = [8] = ) ) Array ( [chk5] = 5 [Submit] = Delete Store(s) ) The script deletes the element that was requested deleted, but for some reason the first element in the array never gets copied. Any help that you can provide would be greatly appreciated. -- Joshua E Minnie CIO [EMAIL PROTECTED] Don't work for recognition, but always do work worthy of recognition. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array elements missing
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;$icount($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