Bug #10810: unset in function doesn't work on global arrays
| From: | Martin dot Sander at touch-screen dot de | Date: | Fri, 11 May 2001 09:53:42 +0000 |
| Subject: | Bug #10810: unset in function doesn't work on global arrays | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-54853@lists.php.net to get a copy of this message | ||
From: Martin.Sander@touch-screen.de
Operating system: RedHat 7.0
PHP version: 4.0.5
PHP Bug Type: Scripting Engine problem
Bug description: unset in function doesn't work on global arrays
unset in function doesn't work on global arrays
example:
<?php
{
function ListIt() {
global $ar;
if (is_array($ar)) {
foreach($ar as $k => $v) {
echo "ar[$k] = $v <br>\n";
}
} else {
echo "empty/nonarray <br>\n";
}
echo "<br>\n";
}
function UnsetOne($i) {
global $ar;
unset($ar[$i]);
}
function UnsetAll() {
global $ar;
//echo "t1s: <br>\n"; ListIt(); echo ":t1e <br>\n";
unset($ar);
//echo "t2s: <br>\n"; ListIt(); echo ":t2e <br>\n";
}
echo "init: <br>\n";
$ar = array();
$ar[1] = "a";
$ar[2] = "b";
$ar[3] = "c";
$ar[4] = "d";
ListIt();
echo "unset 3: <br>\n";
UnsetOne(3);
ListIt();
echo "unset all (global array in function): <br>\n";
UnsetAll();
ListIt();
echo "unset all (top level): <br>\n";
unset($ar);
ListIt();
}
?>
--
Edit Bug report at: http://bugs.php.net/?id=10810&edit=1