ID: 10810 Updated by: derick Reported By: [EMAIL PROTECTED] Old-Status: Open Status: Bogus Bug Type: Scripting Engine problem Operating system: PHP Version: 4.0.5 Assigned To: Comments: Not a bug. The unset ($ar) in the unset all function removes the reference to the global variabele. Use unset($GLOBALS["ar"]) if you want this to work. Derick Previous Comments: --------------------------------------------------------------------------- [2001-05-11 05:53:42] [EMAIL PROTECTED] 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(); } ?> --------------------------------------------------------------------------- ATTENTION! Do NOT reply to this email! To reply, use the web interface found at http://bugs.php.net/?id=10810&edit=2 -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]