Weird $_POST behavior when trying to unset elements
- From: "comp.lang.php" <phillip.s.powell@xxxxxxxxx>
- Date: 27 Nov 2006 23:45:20 -0800
[PHP]
// NEW 11/27/2006: FINALLY, IF YOU ADDED OR DELETED OR DID ANY KIND OF
FORM ACTION SUCCESSFULLY, DON'T RE-DISPLAY THE NEW EXPENSE ITEMS VIA
$_POST
if ($_POST['hasUpdatedLease'] && (!is_array($leaseObj->errorArray) ||
@sizeof($leaseObj->errorArray) == 0)) {
print_r(array_keys($_POST));
@reset($_POST);
$tempPost = $_POST;
foreach ($_POST as $key => $val) if (strpos($key, 'new_') === 0)
array_remove($tempPost, $tempPost[$key]);
@reset($_POST);
$_POST =& $tempPost;
print_r(array_keys($_POST));
}
[/PHP]
For some reason, even though the condition is always met when I click
any of the form submit images, the following "weird behavior patterns"
occur:
1) If I click the "Add" submit image, all $_POST values whose keys
start with "new_" should be removed from $_POST. However,
$_POST['new_audited'] and $_POST['new_reoccuring'] remain
2) If I click the "Delete" submit image, all $_POST values whose keys
start with "new_" should be removed from $_POST. However, *ALL* of
them remain in $_POST untouched!
I can verify that I enter the conditional block by my arrays appearing
on screen every time.
Any reason why this is happening that I missed?
Thanx
Phil
.
- Follow-Ups:
- Re: Weird $_POST behavior when trying to unset elements
- From: Kimmo Laine
- Re: Weird $_POST behavior when trying to unset elements
- Prev by Date: Re: -forgot- Storing objects in a session PHP 5.2.0
- Next by Date: Re: Weird $_POST behavior when trying to unset elements
- Previous by thread: sprintf with dynamic number of elements
- Next by thread: Re: Weird $_POST behavior when trying to unset elements
- Index(es):
Relevant Pages
|